From e34da0ee997c87a7ad5b90dba05f4d1ef341c74f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Sep 2023 15:44:02 +0200 Subject: [PATCH] Tests: use PSR-4 * Ensure all test class names reflect the name of the class under test. * Ensure all test class file names match the name of the test class. * Change the Composer `autoload-dev` directive to use PSR-4 autoloading. * Update the `phpunit.xml.dist` file to match. * Update the `.phpcs.xml.dist` file to match. --- .phpcs.xml.dist | 9 +++++++-- composer.json | 9 +++------ phpunit.xml.dist | 2 +- tests/Unit/{assets-test.php => Assets_Test.php} | 0 .../{configuration-test.php => Configuration_Test.php} | 0 .../{string-store-test.php => String_Store_Test.php} | 0 .../{acf-dependency-test.php => Dependency_ACF_Test.php} | 4 ++-- ...dependency-test.php => Dependency_Yoast_SEO_Test.php} | 4 ++-- ...g-dependency-mock.php => Failing_Dependency_Mock.php} | 0 ...g-dependency-mock.php => Passing_Dependency_Mock.php} | 0 tests/Unit/{main-test.php => Main_Test.php} | 0 tests/Unit/{registry-test.php => Registry_Test.php} | 0 .../{requirements-test.php => Requirements_Test.php} | 0 13 files changed, 15 insertions(+), 13 deletions(-) rename tests/Unit/{assets-test.php => Assets_Test.php} (100%) rename tests/Unit/Configuration/{configuration-test.php => Configuration_Test.php} (100%) rename tests/Unit/Configuration/{string-store-test.php => String_Store_Test.php} (100%) rename tests/Unit/Dependencies/{acf-dependency-test.php => Dependency_ACF_Test.php} (93%) rename tests/Unit/Dependencies/{yoast-seo-dependency-test.php => Dependency_Yoast_SEO_Test.php} (96%) rename tests/Unit/Doubles/{failing-dependency-mock.php => Failing_Dependency_Mock.php} (100%) rename tests/Unit/Doubles/{passing-dependency-mock.php => Passing_Dependency_Mock.php} (100%) rename tests/Unit/{main-test.php => Main_Test.php} (100%) rename tests/Unit/{registry-test.php => Registry_Test.php} (100%) rename tests/Unit/{requirements-test.php => Requirements_Test.php} (100%) diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index f55dd4a..ff47fb4 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -90,7 +90,7 @@ - + @@ -146,7 +146,12 @@ by WPCS. This will most likely be fixed once PHPCS 3.5.0 has been released and WPCS has upgraded to that version. --> - /tests/Unit/Dependencies/yoast-seo-dependency-test\.php$ + /tests/Unit/Dependencies/Dependency_Yoast_SEO_Test\.php$ + + + + + /tests/Unit/*\.php$ diff --git a/composer.json b/composer.json index d4cfff9..4458af1 100644 --- a/composer.json +++ b/composer.json @@ -57,14 +57,11 @@ ] }, "autoload-dev": { - "classmap": [ - "tests/Unit" - ], + "psr-4": { + "Yoast\\WP\\ACF\\Tests\\": "tests/" + }, "files": [ "tests/js/system/data/test-data-loader-functions.php" - ], - "exclude-from-classmap": [ - "/tests/Unit/Doubles/acf.php" ] }, "config": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 828e45d..1d2b560 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,7 +16,7 @@ > - tests/Unit + tests/Unit diff --git a/tests/Unit/assets-test.php b/tests/Unit/Assets_Test.php similarity index 100% rename from tests/Unit/assets-test.php rename to tests/Unit/Assets_Test.php diff --git a/tests/Unit/Configuration/configuration-test.php b/tests/Unit/Configuration/Configuration_Test.php similarity index 100% rename from tests/Unit/Configuration/configuration-test.php rename to tests/Unit/Configuration/Configuration_Test.php diff --git a/tests/Unit/Configuration/string-store-test.php b/tests/Unit/Configuration/String_Store_Test.php similarity index 100% rename from tests/Unit/Configuration/string-store-test.php rename to tests/Unit/Configuration/String_Store_Test.php diff --git a/tests/Unit/Dependencies/acf-dependency-test.php b/tests/Unit/Dependencies/Dependency_ACF_Test.php similarity index 93% rename from tests/Unit/Dependencies/acf-dependency-test.php rename to tests/Unit/Dependencies/Dependency_ACF_Test.php index 0e754da..727d5d4 100644 --- a/tests/Unit/Dependencies/acf-dependency-test.php +++ b/tests/Unit/Dependencies/Dependency_ACF_Test.php @@ -6,11 +6,11 @@ use Yoast_ACF_Analysis_Dependency_ACF; /** - * Class ACF_Dependency_Test. + * Class Dependency_ACF_Test. * * @covers Yoast_ACF_Analysis_Dependency_ACF */ -class ACF_Dependency_Test extends TestCase { +class Dependency_ACF_Test extends TestCase { /** * Tests the situation where no ACF class exists. diff --git a/tests/Unit/Dependencies/yoast-seo-dependency-test.php b/tests/Unit/Dependencies/Dependency_Yoast_SEO_Test.php similarity index 96% rename from tests/Unit/Dependencies/yoast-seo-dependency-test.php rename to tests/Unit/Dependencies/Dependency_Yoast_SEO_Test.php index b6568b1..5b1db4a 100644 --- a/tests/Unit/Dependencies/yoast-seo-dependency-test.php +++ b/tests/Unit/Dependencies/Dependency_Yoast_SEO_Test.php @@ -6,11 +6,11 @@ use Yoast_ACF_Analysis_Dependency_Yoast_SEO; /** - * Class Yoast_SEO_Dependency_Test. + * Class Dependency_Yoast_SEO_Test. * * @covers Yoast_ACF_Analysis_Dependency_Yoast_SEO */ -class Yoast_SEO_Dependency_Test extends TestCase { +class Dependency_Yoast_SEO_Test extends TestCase { /** * Whether or not to preserve the global state. diff --git a/tests/Unit/Doubles/failing-dependency-mock.php b/tests/Unit/Doubles/Failing_Dependency_Mock.php similarity index 100% rename from tests/Unit/Doubles/failing-dependency-mock.php rename to tests/Unit/Doubles/Failing_Dependency_Mock.php diff --git a/tests/Unit/Doubles/passing-dependency-mock.php b/tests/Unit/Doubles/Passing_Dependency_Mock.php similarity index 100% rename from tests/Unit/Doubles/passing-dependency-mock.php rename to tests/Unit/Doubles/Passing_Dependency_Mock.php diff --git a/tests/Unit/main-test.php b/tests/Unit/Main_Test.php similarity index 100% rename from tests/Unit/main-test.php rename to tests/Unit/Main_Test.php diff --git a/tests/Unit/registry-test.php b/tests/Unit/Registry_Test.php similarity index 100% rename from tests/Unit/registry-test.php rename to tests/Unit/Registry_Test.php diff --git a/tests/Unit/requirements-test.php b/tests/Unit/Requirements_Test.php similarity index 100% rename from tests/Unit/requirements-test.php rename to tests/Unit/Requirements_Test.php