From e1e529c60b703d7b84443ee7fd30b077369b9787 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Tue, 23 Jul 2024 09:53:52 +0200 Subject: [PATCH] Update test methods to restore 'old' test notation --- tests/Console/Commands/ComposeTest.php | 12 ++++++++++++ tests/MoverTest.php | 8 ++++++++ tests/replacers/ClassMapReplacerTest.php | 15 +++++++++++++++ tests/replacers/NamespaceReplacerTest.php | 8 +++++++- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/tests/Console/Commands/ComposeTest.php b/tests/Console/Commands/ComposeTest.php index 72a0d714..ea283cfc 100644 --- a/tests/Console/Commands/ComposeTest.php +++ b/tests/Console/Commands/ComposeTest.php @@ -33,6 +33,8 @@ public function setUp(): void * When composer.json is absent, instead of failing with: * "failed to open stream: No such file or directory" * a better message should be written to the OutputInterface. + * + * @test */ #[Test] public function it_fails_gracefully_when_composer_json_absent(): void @@ -58,6 +60,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock) * When json_decode fails, instead of * "Trying to get property 'extra' of non-object" * a better message should be written to the OutputInterface. + * + * @test */ #[Test] public function it_handles_malformed_json_with_grace(): void @@ -87,6 +91,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock) * When composer.json->extra is absent, instead of * "Undefined property: stdClass::$extra" * a better message should be written to the OutputInterface. + * + * @test */ #[Test] public function it_handles_absent_extra_config_with_grace(): void @@ -117,6 +123,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock) * When composer.json->extra is not an object, instead of * "Trying to get property 'mozart' of non-object" * a better message should be written to the OutputInterface. + * + * @test */ #[Test] public function it_handles_malformed_extra_config_with_grace(): void @@ -146,6 +154,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock) * When composer.json->extra->mozart is absent, instead of * "Undefined property: stdClass::$mozart" * a better message should be written to the OutputInterface. + * + * @test */ #[Test] public function it_handles_absent_mozart_config_with_grace(): void @@ -177,6 +187,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock) * a better message should be written to the OutputInterface. * * is_object() added. + * + * @test */ #[Test] public function it_handles_malformed_mozart_config__with_grace(): void diff --git a/tests/MoverTest.php b/tests/MoverTest.php index ac8c3178..4577cc90 100644 --- a/tests/MoverTest.php +++ b/tests/MoverTest.php @@ -59,6 +59,8 @@ public function setUp(): void /** * If the specified `dep_directory` or `classmap_directory` are absent, create them. + * + * @test */ #[Test] public function it_creates_absent_dirs(): void @@ -77,6 +79,8 @@ public function it_creates_absent_dirs(): void /** * If the specified `dep_directory` or `classmap_directory` already exists with contents, it is not an issue. + * + * @test */ #[Test] public function it_is_unpertrubed_by_existing_dirs(): void @@ -107,6 +111,8 @@ public function it_is_unpertrubed_by_existing_dirs(): void /** * If the specified `dep_directory` or `classmap_directory` contains a subdir we are going to need when moving, * delete the subdir. aka: If subfolders exist for dependencies we are about to manage, delete those subfolders. + * + * @test */ #[Test] public function it_deletes_subdirs_for_packages_about_to_be_moved(): void @@ -172,6 +178,8 @@ public function it_deletes_subdirs_for_packages_about_to_be_moved(): void * } * * @see https://github.com/coenjacobs/mozart/issues/89 + * + * @test */ #[Test] public function it_moves_each_file_once_per_namespace() diff --git a/tests/replacers/ClassMapReplacerTest.php b/tests/replacers/ClassMapReplacerTest.php index d81a0375..10b10ce8 100644 --- a/tests/replacers/ClassMapReplacerTest.php +++ b/tests/replacers/ClassMapReplacerTest.php @@ -7,6 +7,7 @@ class ClassMapReplacerTest extends TestCase { + /** @test */ #[Test] public function it_replaces_class_declarations(): void { @@ -17,6 +18,7 @@ public function it_replaces_class_declarations(): void $this->assertEquals('class Mozart_Hello_World {', $contents); } + /** @test */ #[Test] public function it_replaces_abstract_class_declarations(): void { @@ -27,6 +29,7 @@ public function it_replaces_abstract_class_declarations(): void $this->assertEquals('abstract class Mozart_Hello_World {', $contents); } + /** @test */ #[Test] public function it_replaces_interface_class_declarations(): void { @@ -37,6 +40,7 @@ public function it_replaces_interface_class_declarations(): void $this->assertEquals('interface Mozart_Hello_World {', $contents); } + /** @test */ #[Test] public function it_replaces_class_declarations_that_extend_other_classes(): void { @@ -47,6 +51,7 @@ public function it_replaces_class_declarations_that_extend_other_classes(): void $this->assertEquals('class Mozart_Hello_World extends Bye_World {', $contents); } + /** @test */ #[Test] public function it_replaces_class_declarations_that_implement_interfaces(): void { @@ -57,6 +62,7 @@ public function it_replaces_class_declarations_that_implement_interfaces(): void $this->assertEquals('class Mozart_Hello_World implements Bye_World {', $contents); } + /** @test */ #[Test] public function it_stores_replaced_class_names(): void { @@ -67,6 +73,7 @@ public function it_stores_replaced_class_names(): void $this->assertArrayHasKey('Hello_World', $replacer->replacedClasses); } + /** @test */ #[Test] public function it_replaces_class_declarations_psr2(): void { @@ -79,6 +86,8 @@ public function it_replaces_class_declarations_psr2(): void /** * @see https://github.com/coenjacobs/mozart/issues/81 + * + * @test */ #[Test] public function it_replaces_class(): void @@ -94,6 +103,8 @@ public function it_replaces_class(): void /** * @see ClassmapReplacerIntegrationTest::test_it_does_not_make_classname_replacement_inside_namespaced_file() * @see https://github.com/coenjacobs/mozart/issues/93 + * + * @test */ #[Test] public function it_does_not_replace_inside_namespace_multiline(): void @@ -112,6 +123,8 @@ class Hello_World /** * @see ClassmapReplacerIntegrationTest::test_it_does_not_make_classname_replacement_inside_namespaced_file() * @see https://github.com/coenjacobs/mozart/issues/93 + * + * @test */ #[Test] public function it_does_not_replace_inside_namespace_singleline(): void @@ -128,6 +141,8 @@ public function it_does_not_replace_inside_namespace_singleline(): void * It's possible to have multiple namespaces inside one file. * * To have two classes in one file, one in a namespace and the other not, the global namespace needs to be explicit. + * + * @test */ #[Test] public function it_does_not_replace_inside_named_namespace_but_does_inside_explicit_global_namespace(): void diff --git a/tests/replacers/NamespaceReplacerTest.php b/tests/replacers/NamespaceReplacerTest.php index ce539a45..f5856ede 100644 --- a/tests/replacers/NamespaceReplacerTest.php +++ b/tests/replacers/NamespaceReplacerTest.php @@ -37,6 +37,7 @@ protected static function createReplacer(string $namespace, string $prefix = sel return $replacer; } + /** @test */ #[Test] public function it_replaces_namespace_declarations(): void { @@ -46,7 +47,7 @@ public function it_replaces_namespace_declarations(): void $this->assertEquals('namespace My\\Mozart\\Prefix\\Test\\Test;', $contents); } - + /** @test */ #[Test] public function it_doesnt_replaces_namespace_inside_namespace(): void { @@ -58,6 +59,7 @@ public function it_doesnt_replaces_namespace_inside_namespace(): void $this->assertEquals("namespace My\\Mozart\\Prefix\\Test\\Something;\n\nuse My\\Mozart\\Prefix\\Test\\Test;", $contents); } + /** @test */ #[Test] public function it_replaces_partial_namespace_declarations(): void { @@ -67,6 +69,7 @@ public function it_replaces_partial_namespace_declarations(): void $this->assertEquals('namespace My\\Mozart\\Prefix\\Test\\Test\\Another;', $contents); } + /** @test */ #[Test] public function it_doesnt_prefix_already_prefixed_namespace(): void { @@ -78,6 +81,7 @@ public function it_doesnt_prefix_already_prefixed_namespace(): void $this->assertEquals('namespace My\\Mozart\\Prefix\\Test\\Another;', $contents); } + /** @test */ #[Test] public function it_doesnt_double_replace_namespaces_that_also_exist_inside_another_namespace(): void { @@ -108,6 +112,8 @@ public function it_doesnt_double_replace_namespaces_that_also_exist_inside_anoth /** * @see https://github.com/coenjacobs/mozart/issues/75 + * + * @test */ #[Test] public function it_replaces_namespace_use_as_declarations(): void