Skip to content

Commit 80cf9a1

Browse files
committedJun 6, 2023
TASK: Add test composer script
1 parent 833ba07 commit 80cf9a1

File tree

7 files changed

+53
-22
lines changed

7 files changed

+53
-22
lines changed
 

‎.editorconfig

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ indent_size = 2
1818
[*.json]
1919
indent_style = space
2020
indent_size = 2
21+
22+
[*.xml]
23+
indent_style = space
24+
indent_size = 2

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ simple.md
77
test.php
88
error.afx
99
composer.lock
10+
.phpunit.result.cache

‎Makefile

-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +0,0 @@
1-
test::
2-
./vendor/bin/phpunit \
3-
--enforce-time-limit \
4-
--bootstrap vendor/autoload.php \
5-
--testdox test/Integration \
6-
--coverage-html build/coverage-report \
7-
--coverage-filter src
8-
9-
test-unit::
10-
./vendor/bin/phpunit \
11-
--enforce-time-limit \
12-
--bootstrap vendor/autoload.php \
13-
--testdox test/Unit \
14-
--coverage-html build/coverage-report \
15-
--coverage-filter src
16-
17-
test-filter::
18-
./vendor/bin/phpunit \
19-
--bootstrap vendor/autoload.php \
20-
--testdox \
21-
--filter $(filter)

‎README.md

+17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ or, alternatively, directly via:
1717
| script-name | description |
1818
|-|-|
1919
| `analyse` | Run static code analysis with [phpstan](https://phpstan.org/) |
20+
| `test` | Run tests with [phpunit](https://phpunit.de/) |
21+
22+
### Running tests
23+
24+
There's a test suite for unit tests and another one for integration tests. By default both test suites are run entirely. In order to just run one of them, you need to add the `--testsuite` parameter to the script call, e.g.:
25+
26+
```sh
27+
composer test -- --testsuite unit
28+
composer test -- --testsuite integration
29+
```
30+
31+
or alternatively:
32+
33+
```sh
34+
./scripts/test --testsuite unit
35+
./scripts/test --testsuite integration
36+
```
2037

2138
## License
2239

‎composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"type": "library",
44
"license": "GPL-3.0-or-later",
55
"scripts": {
6-
"analyse": "./scripts/analyse"
6+
"analyse": "./scripts/analyse",
7+
"test": "./scripts/test"
78
},
89
"require": {
910
"php": ">=8.1"

‎phpunit.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<phpunit bootstrap="vendor/autoload.php">
2+
<testsuites>
3+
<testsuite name="unit">
4+
<directory>test/Unit</directory>
5+
</testsuite>
6+
<testsuite name="integration">
7+
<directory>test/Integration</directory>
8+
</testsuite>
9+
</testsuites>
10+
</phpunit>

‎scripts/test

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/env bash
2+
3+
##
4+
## Usage (plain):
5+
## ./scripts/test
6+
## ./scripts/test --testsuite unit
7+
## ./scripts/test --testsuite integration
8+
##
9+
## Usage (composer):
10+
## composer test
11+
## composer test -- --testsuite unit
12+
## composer test -- --testsuite integration
13+
##
14+
15+
./vendor/bin/phpunit \
16+
--enforce-time-limit \
17+
--testdox \
18+
--coverage-html build/coverage-report \
19+
--coverage-filter src $@

0 commit comments

Comments
 (0)