Skip to content

Commit bb18527

Browse files
staabmsebastianbergmann
authored andcommitted
added more tests
1 parent 04fc61f commit bb18527

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/unit/Framework/TestCaseTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use function sprintf;
1313
use PHPUnit\Framework\Attributes\CoversClass;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\Attributes\ExcludeGlobalVariableFromBackup;
1516
use PHPUnit\TestFixture\TestWithDifferentNames;
1617

@@ -21,6 +22,15 @@ class TestCaseTest extends TestCase
2122
{
2223
protected static int $testStatic = 456;
2324

25+
public static function provideDataSetAsStringWithData(): iterable
26+
{
27+
yield ['', 'dataSet', []];
28+
29+
yield ["#0 with data ('foo', 'bar')", 0, ['foo', 'bar']];
30+
31+
yield ["@dataSet with data ('foo', 'bar')", 'dataSet', ['foo', 'bar']];
32+
}
33+
2434
public static function setUpBeforeClass(): void
2535
{
2636
$GLOBALS['a'] = 'a';
@@ -83,4 +93,13 @@ public function testGetNameReturnsMethodName(): void
8393

8494
$this->assertSame($methodName, $testCase->nameWithDataSet());
8595
}
96+
97+
#[DataProvider('provideDataSetAsStringWithData')]
98+
public function testDataSetAsStringWithData(string $expectedData, int|string $dataName, array $data): void
99+
{
100+
$testCase = new TestWithDifferentNames('testWithName');
101+
$testCase->setData($dataName, $data);
102+
103+
$this->assertSame($expectedData, $testCase->dataSetAsStringWithData());
104+
}
86105
}

0 commit comments

Comments
 (0)