Skip to content

Commit d0b720f

Browse files
committed
Move DataProvider into own class
1 parent 86e13e2 commit d0b720f

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Redmine\Tests\Fixtures;
6+
7+
use stdClass;
8+
9+
final class TestDataProvider
10+
{
11+
public static function getInvalidProjectIdentifiers(): array
12+
{
13+
return [
14+
'null' => [null],
15+
'true' => [true],
16+
'false' => [false],
17+
'float' => [0.0],
18+
'array' => [[]],
19+
'object' => [new stdClass()],
20+
];
21+
}
22+
}

tests/Unit/Api/IssueCategory/ListNamesByProjectTest.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
use PHPUnit\Framework\Attributes\CoversClass;
88
use PHPUnit\Framework\Attributes\DataProvider;
9+
use PHPUnit\Framework\Attributes\DataProviderExternal;
910
use PHPUnit\Framework\TestCase;
1011
use Redmine\Api\IssueCategory;
1112
use Redmine\Exception\InvalidParameterException;
1213
use Redmine\Http\HttpClient;
1314
use Redmine\Tests\Fixtures\AssertingHttpClient;
14-
use stdClass;
15+
use Redmine\Tests\Fixtures\TestDataProvider;
1516

1617
#[CoversClass(IssueCategory::class)]
1718
class ListNamesByProjectTest extends TestCase
@@ -112,9 +113,9 @@ public function testListNamesByProjectCallsHttpClientOnlyOnce()
112113
}
113114

114115
/**
115-
* @dataProvider getInvalidProjectIdentifiers
116+
* @dataProvider Redmine\Tests\Fixtures\TestDataProvider::getInvalidProjectIdentifiers
116117
*/
117-
#[DataProvider('getInvalidProjectIdentifiers')]
118+
#[DataProviderExternal(TestDataProvider::class, 'getInvalidProjectIdentifiers')]
118119
public function testListNamesByProjectWithWrongProjectIdentifierThrowsException($projectIdentifier)
119120
{
120121
$api = new IssueCategory($this->createMock(HttpClient::class));
@@ -124,16 +125,4 @@ public function testListNamesByProjectWithWrongProjectIdentifierThrowsException(
124125

125126
$api->listNamesByProject($projectIdentifier);
126127
}
127-
128-
public static function getInvalidProjectIdentifiers(): array
129-
{
130-
return [
131-
'null' => [null],
132-
'true' => [true],
133-
'false' => [false],
134-
'float' => [0.0],
135-
'array' => [[]],
136-
'object' => [new stdClass()],
137-
];
138-
}
139128
}

0 commit comments

Comments
 (0)