Skip to content

Commit

Permalink
Tests: Refresh PHPUnit config to add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryJones committed Sep 17, 2023
1 parent 87d6b98 commit 65e44cf
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/.phpunit.cache/
/node_modules/
/vendor/
/.phpcs.xml
/.phpunit.result.cache
/composer.lock
/phpcs.xml
/phpunit.xml
Expand Down
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
}
},
"scripts": {
"coverage": [
"@putenv WP_MULTISITE=1",
"@php ./vendor/bin/phpunit --exclude=ms-excluded --coverage-html ./.phpunit.cache/coverage-html"
],
"coverage-ci": [
"@putenv WP_MULTISITE=1",
"@php ./vendor/bin/phpunit --exclude=ms-excluded"
],
"cs": [
"@php ./vendor/bin/phpcs -p -s -v -n . --standard=\"WordPress-VIP-Go\" --extensions=php --ignore=\"/vendor/*,/node_modules/*,/tests/*\""
],
Expand All @@ -65,11 +73,11 @@
"bash bin/install-wp-tests.sh wordpress_test root root localhost"
],
"integration": [
"@php ./vendor/bin/phpunit --exclude=ms-required"
"@php ./vendor/bin/phpunit --exclude=ms-required --no-coverage"
],
"integration-ms": [
"@putenv WP_MULTISITE=1",
"@php ./vendor/bin/phpunit --exclude=ms-excluded"
"@php ./vendor/bin/phpunit --exclude=ms-excluded --no-coverage"
],
"behat": "run-behat-tests",
"behat-rerun": "rerun-behat-tests",
Expand Down
59 changes: 41 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="tests/Integration/bootstrap.php"
backupGlobals="false"
colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
convertDeprecationsToExceptions="true"
>
<testsuites>
<testsuite name="default">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="tests/Integration/bootstrap.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
colors="true"
failOnRisky="true"
failOnWarning="true"
testdox="true"
verbose="true">
<testsuites>
<testsuite name="Integration">
<directory>tests/Integration</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<file>co-authors-plus.php</file>
<file>template-tags.php</file>
<file>upgrade.php</file>
<directory>php</directory>
</include>
<exclude>
<!-- Inclusion of the next file breaks code coverage with Class "Yoast\WP\SEO\Generators\Schema\Author" not found -->
<file>php/integrations/yoast/class-coauthor.php</file>
<!-- The next view file has a floating $this which breaks PHPUnit coverage. -->
<file>php/integrations/amp/meta-author.php</file>
</exclude>
<report>
<text outputFile="php://stdout"/>
<clover outputFile=".phpunit.cache/clover.xml"/>
</report>
</coverage>
</phpunit>

0 comments on commit 65e44cf

Please sign in to comment.