Skip to content

Commit 9059f20

Browse files
committed
Configure for code coverage
1 parent 07e5beb commit 9059f20

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

.wp-env.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@
44
"phpVersion": "7.4",
55
"config": {
66
"WP_DEBUG": true
7+
},
8+
"env": {
9+
"tests": {
10+
"config": {
11+
"WP_DEBUG": true,
12+
"XDEBUG_MODE": "coverage"
13+
}
14+
}
715
}
816
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"description": "Show a random post on every page load.",
44
"private": true,
55
"scripts": {
6-
"test": "npm run test:phpunit",
7-
"lint": "npx yamllint **/*.yml",
86
"env:start": "wp-env start",
97
"env:stop": "wp-env stop",
108
"env:destroy": "wp-env destroy",
11-
"test:phpunit": "wp-env run tests-cli --env-cwd=wp-content/plugins/random-post-on-refresh vendor/bin/phpunit",
9+
"lint": "npx yamllint **/*.yml",
10+
"test": "npm run test:phpunit",
11+
"test:coverage": "wp-env run tests-cli --env-cwd=wp-content/plugins/random-post-on-refresh composer run test:coverage",
12+
"test:phpunit": "wp-env run tests-cli --env-cwd=wp-content/plugins/random-post-on-refresh composer run test",
1213
"playground": "npx @wp-playground/cli server --blueprint ./playground.json --mountBeforeInstall .:/var/www/html/wp-content/plugins/random-post-on-refresh:writeable --mount ./.github/playground/uploads:/var/www/html/wp-content/uploads"
1314
},
1415
"repository": {

phpunit.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
<include>
1212
<directory suffix=".php">./</directory>
1313
</include>
14+
<exclude>
15+
<directory>./vendor</directory>
16+
<directory>./tests</directory>
17+
<directory>./languages</directory>
18+
<directory>./assets</directory>
19+
</exclude>
20+
<report>
21+
<clover outputFile="coverage.xml" />
22+
<html outputDirectory="coverage" lowUpperBound="50" highLowerBound="90" />
23+
<text outputFile="php://stdout" showUncoveredFiles="true" showOnlySummary="false" />
24+
</report>
1425
</coverage>
1526
<testsuites>
1627
<testsuite name="Plugin Test Suite">

0 commit comments

Comments
 (0)