1111
1212use function sprintf ;
1313use PHPUnit \Framework \Attributes \CoversClass ;
14+ use PHPUnit \Framework \Attributes \DataProvider ;
1415use PHPUnit \Framework \Attributes \ExcludeGlobalVariableFromBackup ;
1516use 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