Skip to content

Commit 71e6e17

Browse files
committed
feat: add phpunits
2 types de tests: unitaire: tester une classe seule sans dépendance = github workflow phpunit.yml intégration: tester jeedom en fonctionnement, utilise docker pour démarrer la bdd et le container jeedom = github workflow docker-test.yml
1 parent 2ca8716 commit 71e6e17

21 files changed

+2308
-523
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
/vendor
3+
/docs

.github/workflows/docker-test.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
# build docker image based on debian bullseye and bookworm
1+
# build docker image based on debian bullseye or bookworm
22
# start both containers and run sick.php
3+
# install composer dev depedencies and run phpunits into running containers
34
# stop & clean
4-
name: Docker Test Image
5+
name: Integrated PHPUnit
56

67
on:
78
# only trigger CI when pull request on following branches
89
pull_request:
910
branches:
1011
- 'alpha'
12+
push:
13+
branches:
14+
- 'feat/run_phpunit'
1115
# this is to manually trigger the worklow
1216
workflow_dispatch:
1317
inputs:
@@ -30,21 +34,26 @@ jobs:
3034
run: |
3135
docker build -t jeedom:bullseye --build-arg DEBIAN=bullseye --build-arg DATABASE=1 .
3236
- name: run jeedom:bullseye and check
33-
# build current image for bullseye and check it
37+
# run current image for bullseye and check it
3438
run: |
3539
docker run -p 80:80 -d --rm --name jeedom_bullseye jeedom:bullseye
3640
sleep 45
3741
docker exec jeedom_bullseye php sick.php
42+
docker exec jeedom_bullseye /bin/bash -c "COMPOSER_NO_DEV=0 && composer install"
43+
docker exec jeedom_bullseye ./vendor/bin/phpunit --testsuite integration
44+
3845
- name: Build jeedom:bookworm
3946
# build current image for bookworm
4047
run: |
4148
docker build -t jeedom:bookworm --build-arg DEBIAN=bookworm --build-arg DATABASE=1 .
4249
- name: run jeedom:bookworm and check
43-
# build current image for bookworm and check it
50+
# run current image for bookworm and check it
4451
run: |
4552
docker run -p 81:80 -d --rm --name jeedom_bookworm jeedom:bookworm
4653
sleep 45
4754
docker exec jeedom_bookworm php sick.php
55+
docker exec jeedom_bookworm /bin/bash -c "COMPOSER_NO_DEV=0 && composer install"
56+
docker exec jeedom_bookworm ./vendor/bin/phpunit --testsuite integration
4857
4958
- name: Clean docker image
5059
continue-on-error: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ tmp/*
4545

4646
!.htaccess
4747
.env
48+
.phpunit.result.cache
4849
.phpstan.cache
4950
phpstan.phar

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,5 @@ EXPOSE 80
6464
EXPOSE 443
6565
COPY --chown=root:root --chmod=550 install/OS_specific/Docker/init.sh /root/
6666
COPY --chown=root:root --chmod=550 install/bashrc /root/.bashrc
67-
CMD ["bash", "/root/init.sh"]
67+
SHELL ["/bin/bash", "-c"]
68+
CMD ["/root/init.sh"]

composer.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
"symfony/expression-language": "5 - 7",
55
"pragmarx/google2fa-qrcode": "^3",
66
"bacon/bacon-qr-code": "2 - 3",
7-
"influxdata/influxdb-client-php": "^3",
8-
"psr/log": "^1.1",
9-
"php": ">=7.4"
7+
"influxdb/influxdb-php": "^1.15",
8+
"psr/log": "^1.1"
109
},
1110
"config": {
12-
"allow-plugins": {
13-
"php-http/discovery": true
14-
},
15-
"platform": {
16-
"php": "7.4"
17-
}
11+
"allow-plugins": {
12+
"php-http/discovery": true
13+
}
14+
},
15+
"require-dev": {
16+
"phpunit/phpunit": "^9.6"
1817
}
1918
}

0 commit comments

Comments
 (0)