Skip to content

Commit 72ff8a1

Browse files
committed
phpunit code coverage / composer scripts added.
1 parent 3c0a06d commit 72ff8a1

File tree

5 files changed

+49
-13
lines changed

5 files changed

+49
-13
lines changed

.idea/runConfigurations/SimpleTestCase.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
"url": "https://www.paypal.me/syslogic"
2222
}],
2323
"scripts": {
24-
"test": "XDEBUG_MODE=coverage vendor/bin/phpunit --bootstrap vendor/autoload.php --configuration phpunit.xml --testsuite main",
25-
"start": [ "Composer\\Config::disableProcessTimeout", "FUNCTION_TARGET=on_https php -S localhost:${PORT:-8081} vendor/bin/router.php"
26-
]
24+
"test": "vendor/bin/phpunit --bootstrap vendor/autoload.php --configuration phpunit.xml --testsuite main",
25+
"start": [ "Composer\\Config::disableProcessTimeout", "FUNCTION_TARGET=on_https php -S localhost:${PORT:-8081} vendor/bin/router.php"],
26+
"coverage_linux": "export XDEBUG_MODE=coverage && vendor/bin/phpunit --bootstrap vendor/autoload.php --configuration coverage.xml --testsuite main",
27+
"coverage_windows": "setlocal xdebug.mode=coverage && %cd%/vendor/bin/phpunit --bootstrap vendor/autoload.php --configuration coverage.xml --testsuite main"
2728
},
2829
"scripts-descriptions": {
2930
"test": "Run PHPunit tests",
30-
"start": "Call function on_https"
31+
"start": "Call function on_https",
32+
"coverage_linux": "Run PHPUnit tests with code coverage on Linux",
33+
"coverage_windows": "Run PHPUnit tests with code coverage on Windows"
3134
},
3235
"repositories": [],
3336
"require": {
@@ -40,9 +43,11 @@
4043
"guzzlehttp/psr7": "^2.4.3"
4144
},
4245
"require-dev": {
43-
"phpunit/phpunit": "^9.6.0",
46+
"phpunit/phpunit": "^9.6.3",
47+
"phpunit/php-code-coverage": "^9.2.24",
4448
"google/cloud-tools": "^0.13.0"
4549
},
50+
4651
"autoload": {
4752
"psr-4": {
4853
"CloudFunctions\\": "src"

coverage.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- https://phpunit.readthedocs.io/en/10.0/configuration.html -->
3+
<phpunit
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
6+
verbose="true"
7+
colors="true">
8+
9+
<testsuites>
10+
<testsuite name="main">
11+
<directory>tests</directory>
12+
</testsuite>
13+
</testsuites>
14+
15+
<coverage>
16+
<include>
17+
<directory suffix=".php">src</directory>
18+
</include>
19+
<report>
20+
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/>
21+
<text outputFile="php://stdout" showUncoveredFiles="true"/>
22+
</report>
23+
</coverage>
24+
25+
<logging>
26+
<testdoxHtml outputFile="build/testdox.html"/>
27+
</logging>
28+
29+
</phpunit>

phpunit.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit colors="true">
3-
<php>
2+
<!-- https://phpunit.readthedocs.io/en/10.0/configuration.html -->
3+
<phpunit
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
6+
colors="true">
47

5-
</php>
8+
<php/>
69

710
<coverage>
811
<include>
@@ -16,7 +19,7 @@
1619

1720
<testsuites>
1821
<testsuite name="main">
19-
<directory suffix="TestCase.php">./tests</directory>
22+
<directory>tests</directory>
2023
</testsuite>
2124
</testsuites>
2225

tests/SimpleTestCase.php renamed to tests/SimpleTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
use PHPUnit\Framework\TestCase;
88

99
/**
10-
* Class Simple TestCase.
11-
*
10+
* Simple {@link TestCase}
1211
* @author Martin Zeitler
1312
* @version 1.0.0
1413
*/
15-
class SimpleTestCase extends TestCase {
14+
class SimpleTest extends TestCase {
1615

1716
private static string $project_id;
1817
private static array $json_data;

0 commit comments

Comments
 (0)