Skip to content

Commit fb6c6bc

Browse files
authored
dev: php-tuf#143 Add basic PHPUnit code coverage setup (php-tuf#144)
1 parent 5943d89 commit fb6c6bc

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/.phpunit.result.cache
12
/composer.lock
23
/phpstan.neon
4+
/var
35
/vendor

DEVELOP.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ To run a single test use PHPUnit's `--filter` option:
2121
ddev exec phpunit ./tests --debug --filter=testCannotProtectNonComposerRepository
2222
```
2323

24+
### Checking code coverage
25+
26+
```
27+
ddev xdebug
28+
ddev composer coverage
29+
```
30+
2431
## Linting and fixing
2532

2633
Linting for syntax, then style:

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
"slevomat/coding-standard": "^8.28"
4545
},
4646
"scripts": {
47+
"coverage": [
48+
"@putenv XDEBUG_MODE=coverage",
49+
"phpunit --coverage-text --color=always --testdox"
50+
],
4751
"phpcs": "phpcs",
4852
"phpcbf": "phpcbf",
4953
"phpstan": "phpstan",

phpunit.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<phpunit
2+
bootstrap="vendor/autoload.php"
3+
colors="true"
4+
convertErrorsToExceptions="true"
5+
convertNoticesToExceptions="true"
6+
convertWarningsToExceptions="true">
7+
<testsuites>
8+
<testsuite name="Tests">
9+
<directory>tests</directory>
10+
</testsuite>
11+
</testsuites>
12+
<coverage cacheDirectory="var/phpunit/coverage-cache" processUncoveredFiles="true">
13+
<include>
14+
<directory suffix=".php">src</directory>
15+
</include>
16+
</coverage>
17+
</phpunit>

0 commit comments

Comments
 (0)