1414use PHPUnit \Framework \Attributes \Group ;
1515use PHPUnit \Framework \Attributes \Small ;
1616use PHPUnit \Framework \TestCase ;
17+ use PHPUnit \TestFixture \BackedEnumeration ;
18+ use PHPUnit \TestFixture \Enumeration ;
1719use PHPUnit \TestFixture \TestDox \TestDoxAttributeOnTestClassTest ;
20+ use PHPUnit \TestFixture \TestDoxTest ;
21+ use stdClass ;
1822
1923#[CoversClass(NamePrettifier::class)]
2024#[Group('testdox ' )]
@@ -123,6 +127,58 @@ public static function methodNameProvider(): array
123127 ];
124128 }
125129
130+ /**
131+ * @return non-empty-list<array{0: non-empty-string, 1: TestCase, 2: bool}>
132+ */
133+ public static function objectProvider (): array
134+ {
135+ $ object = new class {
136+ public function __toString (): string
137+ {
138+ return 'object as string ' ;
139+ }
140+ };
141+
142+ $ data = [['string ' ], true , 0.0 , 1 , 'string ' , $ object , new stdClass , Enumeration::Test, BackedEnumeration::Test, null , '' ];
143+
144+ $ testWithDataWithIntegerKey = new TestDoxTest ('testTwo ' );
145+ $ testWithDataWithIntegerKey ->setData (0 , $ data );
146+
147+ $ testWithDataWithStringKey = new TestDoxTest ('testTwo ' );
148+ $ testWithDataWithStringKey ->setData ('a ' , $ data );
149+
150+ $ testWithDataAndTestDoxPlaceholders = new TestDoxTest ('testFour ' );
151+ $ testWithDataAndTestDoxPlaceholders ->setData ('a ' , $ data );
152+
153+ return [
154+ [
155+ 'One ' ,
156+ new TestDoxTest ('testOne ' ),
157+ false ,
158+ ],
159+ [
160+ 'Two with data set #0 ' ,
161+ $ testWithDataWithIntegerKey ,
162+ false ,
163+ ],
164+ [
165+ 'Two with data set "a" ' ,
166+ $ testWithDataWithStringKey ,
167+ false ,
168+ ],
169+ [
170+ 'This is a custom test description ' ,
171+ new TestDoxTest ('testThree ' ),
172+ false ,
173+ ],
174+ [
175+ 'This is a custom test description with placeholders array true 0.0 1 string object as string stdClass Test test null \'\' default ' ,
176+ $ testWithDataAndTestDoxPlaceholders ,
177+ false ,
178+ ],
179+ ];
180+ }
181+
126182 /**
127183 * @param non-empty-string $expected
128184 * @param non-empty-string $className
@@ -142,4 +198,13 @@ public function testNameOfTestMethodCanBePrettified(string $expected, string $me
142198 {
143199 $ this ->assertSame ($ expected , (new NamePrettifier )->prettifyTestMethodName ($ methodName ));
144200 }
201+
202+ /**
203+ * @param non-empty-string $expected
204+ */
205+ #[DataProvider('objectProvider ' )]
206+ public function test_TestCase_can_be_prettified (string $ expected , TestCase $ testCase , bool $ colorize ): void
207+ {
208+ $ this ->assertSame ($ expected , (new NamePrettifier )->prettifyTestCase ($ testCase , $ colorize ));
209+ }
145210}
0 commit comments