From c4defab8b46fc2e396ba08ade55933c8853f583a Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 28 Nov 2024 16:46:17 +0100 Subject: [PATCH 1/6] Update Psalm baseline --- .psalm/baseline.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.psalm/baseline.xml b/.psalm/baseline.xml index a99a95aae2c..694b54d2af0 100644 --- a/.psalm/baseline.xml +++ b/.psalm/baseline.xml @@ -585,11 +585,6 @@ - - - - - From c1511786e357b0f4dc9d76ca9a36d6d18e5b67ff Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 28 Nov 2024 16:49:43 +0100 Subject: [PATCH 2/6] Revert "Add test" This reverts commit 492c3ae88819ccac578ce04cff7e7415d02f140e. --- .../_files/TestDoxAttributeOnTestClassTest.php | 18 ------------------ .../Logging/TestDox/NamePrettifierTest.php | 2 -- 2 files changed, 20 deletions(-) delete mode 100644 tests/_files/TestDoxAttributeOnTestClassTest.php diff --git a/tests/_files/TestDoxAttributeOnTestClassTest.php b/tests/_files/TestDoxAttributeOnTestClassTest.php deleted file mode 100644 index c80a893998f..00000000000 --- a/tests/_files/TestDoxAttributeOnTestClassTest.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace PHPUnit\TestFixture\TestDox; - -use PHPUnit\Framework\Attributes\TestDox; -use PHPUnit\Framework\TestCase; - -#[TestDox('Custom Title')] -final class TestDoxAttributeOnTestClassTest extends TestCase -{ -} diff --git a/tests/unit/Logging/TestDox/NamePrettifierTest.php b/tests/unit/Logging/TestDox/NamePrettifierTest.php index fceae02c4ab..3d36a0ac76f 100644 --- a/tests/unit/Logging/TestDox/NamePrettifierTest.php +++ b/tests/unit/Logging/TestDox/NamePrettifierTest.php @@ -14,7 +14,6 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Small; use PHPUnit\Framework\TestCase; -use PHPUnit\TestFixture\TestDox\TestDoxAttributeOnTestClassTest; #[CoversClass(NamePrettifier::class)] #[Group('testdox')] @@ -36,7 +35,6 @@ public static function classNameProvider(): array ['Unnamed Tests', 'TestTest'], ['Système Testé', 'SystèmeTestéTest'], ['Expression Évaluée', 'ExpressionÉvaluéeTest'], - ['Custom Title', TestDoxAttributeOnTestClassTest::class], ]; } From 5eafb58c8cfc6bccaaa030a94b76ad729cc9198e Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 28 Nov 2024 16:49:51 +0100 Subject: [PATCH 3/6] Revert "Refactor tests" This reverts commit f126c9f33be245c192303780916e05c1216572f9. --- .../Logging/TestDox/NamePrettifierTest.php | 73 ++++++------------- 1 file changed, 23 insertions(+), 50 deletions(-) diff --git a/tests/unit/Logging/TestDox/NamePrettifierTest.php b/tests/unit/Logging/TestDox/NamePrettifierTest.php index 3d36a0ac76f..ff8621ae22f 100644 --- a/tests/unit/Logging/TestDox/NamePrettifierTest.php +++ b/tests/unit/Logging/TestDox/NamePrettifierTest.php @@ -10,7 +10,6 @@ namespace PHPUnit\Logging\TestDox; use PHPUnit\Framework\Attributes\CoversClass; -use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Small; use PHPUnit\Framework\TestCase; @@ -20,61 +19,35 @@ #[Small] final class NamePrettifierTest extends TestCase { - /** - * @return non-empty-list - */ - public static function classNameProvider(): array + public function testTitleHasSensibleDefaults(): void { - return [ - ['Foo', 'FooTest'], - ['Foo', 'TestFoo'], - ['Foo', 'TestsFoo'], - ['Foo', 'TestFooTest'], - ['Foo (Test\Foo)', 'Test\FooTest'], - ['Foo (Tests\Foo)', 'Tests\FooTest'], - ['Unnamed Tests', 'TestTest'], - ['Système Testé', 'SystèmeTestéTest'], - ['Expression Évaluée', 'ExpressionÉvaluéeTest'], - ]; + $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('FooTest')); + $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('TestFoo')); + $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('TestsFoo')); + $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('TestFooTest')); + $this->assertEquals('Foo (Test\Foo)', (new NamePrettifier)->prettifyTestClassName('Test\FooTest')); + $this->assertEquals('Foo (Tests\Foo)', (new NamePrettifier)->prettifyTestClassName('Tests\FooTest')); + $this->assertEquals('Unnamed Tests', (new NamePrettifier)->prettifyTestClassName('TestTest')); + $this->assertEquals('Système Testé', (new NamePrettifier)->prettifyTestClassName('SystèmeTestéTest')); + $this->assertEquals('Expression Évaluée', (new NamePrettifier)->prettifyTestClassName('ExpressionÉvaluéeTest')); } - /** - * @return non-empty-list - */ - public static function methodNameProvider(): array + public function testTestNameIsConvertedToASentence(): void { - return [ - ['', ''], - ['', 'test'], - ['This is a test', 'testThisIsATest'], - ['This is a test', 'testThisIsATest2'], - ['This is a test', 'this_is_a_test'], - ['This is a test', 'test_this_is_a_test'], - ['Foo for bar is 0', 'testFooForBarIs0'], - ['Foo for baz is 1', 'testFooForBazIs1'], - ['This has a 123 in its name', 'testThisHasA123InItsName'], - ['Sets redirect header on 301', 'testSetsRedirectHeaderOn301'], - ['Sets redirect header on 302', 'testSetsRedirectHeaderOn302'], - ]; + $this->assertEquals('', (new NamePrettifier)->prettifyTestMethodName('')); + $this->assertEquals('This is a test', (new NamePrettifier)->prettifyTestMethodName('testThisIsATest')); + $this->assertEquals('This is a test', (new NamePrettifier)->prettifyTestMethodName('testThisIsATest2')); + $this->assertEquals('This is a test', (new NamePrettifier)->prettifyTestMethodName('this_is_a_test')); + $this->assertEquals('This is a test', (new NamePrettifier)->prettifyTestMethodName('test_this_is_a_test')); + $this->assertEquals('Foo for bar is 0', (new NamePrettifier)->prettifyTestMethodName('testFooForBarIs0')); + $this->assertEquals('Foo for baz is 1', (new NamePrettifier)->prettifyTestMethodName('testFooForBazIs1')); + $this->assertEquals('This has a 123 in its name', (new NamePrettifier)->prettifyTestMethodName('testThisHasA123InItsName')); + $this->assertEquals('', (new NamePrettifier)->prettifyTestMethodName('test')); } - /** - * @param non-empty-string $expected - * @param non-empty-string $className - */ - #[DataProvider('classNameProvider')] - public function testNameOfTestClassCanBePrettified(string $expected, string $className): void + public function testTestNameIsNotGroupedWhenNotInSequence(): void { - $this->assertSame($expected, (new NamePrettifier)->prettifyTestClassName($className)); - } - - /** - * @param non-empty-string $expected - * @param non-empty-string $methodName - */ - #[DataProvider('methodNameProvider')] - public function testNameOfTestMethodCanBePrettified(string $expected, string $methodName): void - { - $this->assertSame($expected, (new NamePrettifier)->prettifyTestMethodName($methodName)); + $this->assertEquals('Sets redirect header on 301', (new NamePrettifier)->prettifyTestMethodName('testSetsRedirectHeaderOn301')); + $this->assertEquals('Sets redirect header on 302', (new NamePrettifier)->prettifyTestMethodName('testSetsRedirectHeaderOn302')); } } From 586d09916e899e4c90091175874a4b89c6156c11 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 28 Nov 2024 16:51:39 +0100 Subject: [PATCH 4/6] Rename tests --- tests/unit/Logging/TestDox/NamePrettifierTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/Logging/TestDox/NamePrettifierTest.php b/tests/unit/Logging/TestDox/NamePrettifierTest.php index ff8621ae22f..a9b9ca62561 100644 --- a/tests/unit/Logging/TestDox/NamePrettifierTest.php +++ b/tests/unit/Logging/TestDox/NamePrettifierTest.php @@ -19,7 +19,7 @@ #[Small] final class NamePrettifierTest extends TestCase { - public function testTitleHasSensibleDefaults(): void + public function testNameOfTestClassCanBePrettified(): void { $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('FooTest')); $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('TestFoo')); @@ -32,7 +32,7 @@ public function testTitleHasSensibleDefaults(): void $this->assertEquals('Expression Évaluée', (new NamePrettifier)->prettifyTestClassName('ExpressionÉvaluéeTest')); } - public function testTestNameIsConvertedToASentence(): void + public function testNameOfTestMethodCanBePrettified(): void { $this->assertEquals('', (new NamePrettifier)->prettifyTestMethodName('')); $this->assertEquals('This is a test', (new NamePrettifier)->prettifyTestMethodName('testThisIsATest')); From b7f5f5339830fc3de94feeb0016b9569879d3921 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 28 Nov 2024 16:52:10 +0100 Subject: [PATCH 5/6] Reorganize tests --- .../Logging/TestDox/NamePrettifierTest.php | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/tests/unit/Logging/TestDox/NamePrettifierTest.php b/tests/unit/Logging/TestDox/NamePrettifierTest.php index a9b9ca62561..42aa5b76fee 100644 --- a/tests/unit/Logging/TestDox/NamePrettifierTest.php +++ b/tests/unit/Logging/TestDox/NamePrettifierTest.php @@ -21,33 +21,29 @@ final class NamePrettifierTest extends TestCase { public function testNameOfTestClassCanBePrettified(): void { - $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('FooTest')); - $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('TestFoo')); - $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('TestsFoo')); - $this->assertEquals('Foo', (new NamePrettifier)->prettifyTestClassName('TestFooTest')); - $this->assertEquals('Foo (Test\Foo)', (new NamePrettifier)->prettifyTestClassName('Test\FooTest')); - $this->assertEquals('Foo (Tests\Foo)', (new NamePrettifier)->prettifyTestClassName('Tests\FooTest')); - $this->assertEquals('Unnamed Tests', (new NamePrettifier)->prettifyTestClassName('TestTest')); - $this->assertEquals('Système Testé', (new NamePrettifier)->prettifyTestClassName('SystèmeTestéTest')); - $this->assertEquals('Expression Évaluée', (new NamePrettifier)->prettifyTestClassName('ExpressionÉvaluéeTest')); + $this->assertSame('Foo', (new NamePrettifier)->prettifyTestClassName('FooTest')); + $this->assertSame('Foo', (new NamePrettifier)->prettifyTestClassName('TestFoo')); + $this->assertSame('Foo', (new NamePrettifier)->prettifyTestClassName('TestsFoo')); + $this->assertSame('Foo', (new NamePrettifier)->prettifyTestClassName('TestFooTest')); + $this->assertSame('Foo (Test\Foo)', (new NamePrettifier)->prettifyTestClassName('Test\FooTest')); + $this->assertSame('Foo (Tests\Foo)', (new NamePrettifier)->prettifyTestClassName('Tests\FooTest')); + $this->assertSame('Unnamed Tests', (new NamePrettifier)->prettifyTestClassName('TestTest')); + $this->assertSame('Système Testé', (new NamePrettifier)->prettifyTestClassName('SystèmeTestéTest')); + $this->assertSame('Expression Évaluée', (new NamePrettifier)->prettifyTestClassName('ExpressionÉvaluéeTest')); } public function testNameOfTestMethodCanBePrettified(): void { - $this->assertEquals('', (new NamePrettifier)->prettifyTestMethodName('')); - $this->assertEquals('This is a test', (new NamePrettifier)->prettifyTestMethodName('testThisIsATest')); - $this->assertEquals('This is a test', (new NamePrettifier)->prettifyTestMethodName('testThisIsATest2')); - $this->assertEquals('This is a test', (new NamePrettifier)->prettifyTestMethodName('this_is_a_test')); - $this->assertEquals('This is a test', (new NamePrettifier)->prettifyTestMethodName('test_this_is_a_test')); - $this->assertEquals('Foo for bar is 0', (new NamePrettifier)->prettifyTestMethodName('testFooForBarIs0')); - $this->assertEquals('Foo for baz is 1', (new NamePrettifier)->prettifyTestMethodName('testFooForBazIs1')); - $this->assertEquals('This has a 123 in its name', (new NamePrettifier)->prettifyTestMethodName('testThisHasA123InItsName')); - $this->assertEquals('', (new NamePrettifier)->prettifyTestMethodName('test')); - } - - public function testTestNameIsNotGroupedWhenNotInSequence(): void - { - $this->assertEquals('Sets redirect header on 301', (new NamePrettifier)->prettifyTestMethodName('testSetsRedirectHeaderOn301')); - $this->assertEquals('Sets redirect header on 302', (new NamePrettifier)->prettifyTestMethodName('testSetsRedirectHeaderOn302')); + $this->assertSame('', (new NamePrettifier)->prettifyTestMethodName('')); + $this->assertSame('', (new NamePrettifier)->prettifyTestMethodName('test')); + $this->assertSame('This is a test', (new NamePrettifier)->prettifyTestMethodName('testThisIsATest')); + $this->assertSame('This is a test', (new NamePrettifier)->prettifyTestMethodName('testThisIsATest2')); + $this->assertSame('This is a test', (new NamePrettifier)->prettifyTestMethodName('this_is_a_test')); + $this->assertSame('This is a test', (new NamePrettifier)->prettifyTestMethodName('test_this_is_a_test')); + $this->assertSame('Foo for bar is 0', (new NamePrettifier)->prettifyTestMethodName('testFooForBarIs0')); + $this->assertSame('Foo for baz is 1', (new NamePrettifier)->prettifyTestMethodName('testFooForBazIs1')); + $this->assertSame('This has a 123 in its name', (new NamePrettifier)->prettifyTestMethodName('testThisHasA123InItsName')); + $this->assertSame('Sets redirect header on 301', (new NamePrettifier)->prettifyTestMethodName('testSetsRedirectHeaderOn301')); + $this->assertSame('Sets redirect header on 302', (new NamePrettifier)->prettifyTestMethodName('testSetsRedirectHeaderOn302')); } } From 01edd70a4bc36cdc59c58e0be811f007b6548ce6 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 28 Nov 2024 16:53:07 +0100 Subject: [PATCH 6/6] Add test --- .../_files/TestDoxAttributeOnTestClassTest.php | 18 ++++++++++++++++++ .../Logging/TestDox/NamePrettifierTest.php | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 tests/_files/TestDoxAttributeOnTestClassTest.php diff --git a/tests/_files/TestDoxAttributeOnTestClassTest.php b/tests/_files/TestDoxAttributeOnTestClassTest.php new file mode 100644 index 00000000000..c80a893998f --- /dev/null +++ b/tests/_files/TestDoxAttributeOnTestClassTest.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\TestDox; + +use PHPUnit\Framework\Attributes\TestDox; +use PHPUnit\Framework\TestCase; + +#[TestDox('Custom Title')] +final class TestDoxAttributeOnTestClassTest extends TestCase +{ +} diff --git a/tests/unit/Logging/TestDox/NamePrettifierTest.php b/tests/unit/Logging/TestDox/NamePrettifierTest.php index 42aa5b76fee..6cfabc6b0ac 100644 --- a/tests/unit/Logging/TestDox/NamePrettifierTest.php +++ b/tests/unit/Logging/TestDox/NamePrettifierTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Small; use PHPUnit\Framework\TestCase; +use PHPUnit\TestFixture\TestDox\TestDoxAttributeOnTestClassTest; #[CoversClass(NamePrettifier::class)] #[Group('testdox')] @@ -30,6 +31,7 @@ public function testNameOfTestClassCanBePrettified(): void $this->assertSame('Unnamed Tests', (new NamePrettifier)->prettifyTestClassName('TestTest')); $this->assertSame('Système Testé', (new NamePrettifier)->prettifyTestClassName('SystèmeTestéTest')); $this->assertSame('Expression Évaluée', (new NamePrettifier)->prettifyTestClassName('ExpressionÉvaluéeTest')); + $this->assertSame('Custom Title', (new NamePrettifier)->prettifyTestClassName(TestDoxAttributeOnTestClassTest::class)); } public function testNameOfTestMethodCanBePrettified(): void