Skip to content

Commit dd076b0

Browse files
🔧 Setup PHPUnit
1 parent 785edde commit dd076b0

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
test:
11+
name: Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v4
17+
18+
- name: Configure PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.2
22+
tools: composer:v2
23+
24+
- name: Install dependencies
25+
run: composer install --prefer-dist --no-progress
26+
27+
- name: Running unit test
28+
run: composer phpunit

‎composer.json‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"Dbout\\WpHook\\": "src/"
2525
}
2626
},
27+
"autoload-dev": {
28+
"psr-4": {
29+
"Dbout\\WpHook\\Tests\\": "tests/"
30+
}
31+
},
2732
"require": {
2833
"php": ">=8.2",
2934
"psr/cache": "^1.0|^2.0|^3.0"
@@ -34,13 +39,15 @@
3439
"friendsofphp/php-cs-fixer": "^3.65",
3540
"roots/wordpress": "^6.7",
3641
"szepeviktor/phpstan-wordpress": "^2.0",
37-
"phpstan/extension-installer": "^1.4"
42+
"phpstan/extension-installer": "^1.4",
43+
"phpunit/phpunit": "^12.0"
3844
},
3945
"scripts": {
4046
"rector": "vendor/bin/rector process src --dry-run",
4147
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon",
4248
"csFixer:check": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
43-
"csFixer": "vendor/bin/php-cs-fixer fix"
49+
"csFixer": "vendor/bin/php-cs-fixer fix",
50+
"phpunit": "vendor/bin/phpunit"
4451
},
4552
"config": {
4653
"allow-plugins": {

‎phpunit.xml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit cacheResult="false" stopOnError="true">
3+
<testsuites>
4+
<testsuite name="Tests">
5+
<directory>tests/</directory>
6+
</testsuite>
7+
</testsuites>
8+
</phpunit>

0 commit comments

Comments
 (0)