11
11
12
12
use function sprintf ;
13
13
use PHPUnit \Framework \Attributes \CoversClass ;
14
+ use PHPUnit \Framework \Attributes \DataProvider ;
14
15
use PHPUnit \Framework \Attributes \ExcludeGlobalVariableFromBackup ;
15
16
use PHPUnit \TestFixture \TestWithDifferentNames ;
16
17
@@ -21,6 +22,15 @@ class TestCaseTest extends TestCase
21
22
{
22
23
protected static int $ testStatic = 456 ;
23
24
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
+
24
34
public static function setUpBeforeClass (): void
25
35
{
26
36
$ GLOBALS ['a ' ] = 'a ' ;
@@ -83,4 +93,13 @@ public function testGetNameReturnsMethodName(): void
83
93
84
94
$ this ->assertSame ($ methodName , $ testCase ->nameWithDataSet ());
85
95
}
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
+ }
86
105
}
0 commit comments