Skip to content

Commit 2749378

Browse files
committed
Set up PHPUnit for unit tests
1 parent 86755ae commit 2749378

8 files changed

+1811
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/node_modules/
2+
/vendor/
23
/wpcs/

.prettierignore

-1
This file was deleted.

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules/
2+
/vendor/
3+
/wpcs/
4+
/*.lock

README.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,33 @@ pictures!
55

66
## Contributing
77

8+
### Running the unit tests
9+
10+
#### Setting up PHPUnit
11+
12+
Install [PHPUnit](https://phpunit.readthedocs.io/en/9.5/installation.html)
13+
with:
14+
15+
```bash
16+
$ sudo apt install composer
17+
$ composer install
18+
```
19+
20+
#### Running PHPUnit
21+
22+
Run the unit tests with:
23+
24+
```bash
25+
$ composer test
26+
```
27+
828
### Formatting the code
929

1030
Pull and run [prettier](https://github.com/prettier/plugin-php) with:
1131

1232
```bash
13-
$ yarn install
14-
$ yarn run prettier --write .
33+
$ yarn install # pull
34+
$ composer format # run
1535
```
1636

1737
### Validating against WordPress coding standards
@@ -64,5 +84,5 @@ $ popd
6484
Run PHP_CodeSniffer with:
6585

6686
```bash
67-
$ ./wpcs/vendor/bin/phpcs -s
87+
$ composer lint
6888
```

composer.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"require-dev": {
3+
"phpunit/phpunit": "^9.5.25"
4+
},
5+
"scripts": {
6+
"format": "yarn run prettier --write . || yarnpkg run prettier --write .",
7+
"lint": "./wpcs/vendor/bin/phpcs -s",
8+
"test": "./vendor/bin/phpunit"
9+
}
10+
}

0 commit comments

Comments
 (0)