Skip to content

Commit

Permalink
Tests: use PSR-4
Browse files Browse the repository at this point in the history
* Ensure subdirectory names use "ProperCase".
* 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.
  • Loading branch information
jrfnl committed Nov 20, 2023
1 parent b0695e6 commit 97eceea
Show file tree
Hide file tree
Showing 33 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,12 @@
<exclude-pattern>/src/watchers/republished-post-watcher\.php$</exclude-pattern>
</rule>

<!-- The below two issues will be fixed in YoastCS 3.0, after which these excludes can be removed. -->
<rule ref="Yoast.Commenting.FileComment.Unnecessary">
<exclude-pattern>/tests/*/bootstrap\.php$</exclude-pattern>
</rule>
<rule ref="Yoast.Files.FileName.InvalidClassFileName">
<exclude-pattern>/tests/*\.php$</exclude-pattern>
</rule>

</ruleset>
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
]
},
"autoload-dev": {
"classmap": [
"tests/"
]
"psr-4": {
"Yoast\\WP\\Duplicate_Post\\Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
Expand Down
4 changes: 2 additions & 2 deletions phpunit-wp.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/wp/bootstrap.php"
bootstrap="tests/WP/bootstrap.php"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
Expand All @@ -20,7 +20,7 @@
>
<testsuites>
<testsuite name="duplicatepost">
<directory suffix="-test.php">./tests/wp</directory>
<directory suffix="Test.php">./tests/WP</directory>
</testsuite>
</testsuites>

Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/unit/bootstrap.php"
bootstrap="tests/Unit/bootstrap.php"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
Expand All @@ -20,7 +20,7 @@
>
<testsuites>
<testsuite name="duplicatepost">
<directory suffix="-test.php">./tests/unit</directory>
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 97eceea

Please sign in to comment.