Skip to content

Commit 357c279

Browse files
committed
😔 chore: setting up test coverage report (for some reason the hot reload stop to working 😔).
1 parent b1dc0d4 commit 357c279

7 files changed

Lines changed: 24 additions & 7 deletions

File tree

‎.vscode/settings.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"command-runner.commands": {
66
"Run PhpStan": "docker compose exec flykit vendor/bin/phpstan analyse -l 2 app",
77
"Run Phpcs": "docker compose exec flykit composer cs-fix",
8-
"Run Hyperf Unit Tests": "docker compose exec flykit composer test"
8+
"Run Hyperf Unit Tests": "docker compose exec flykit composer coverage && open ./backend/.phpunit.cache/coverage/index.html"
99
}
1010
}

‎backend/composer.json‎

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"rm -rf runtime/container"
7474
],
7575
"test": "co-phpunit --prepend test/bootstrap.php --colors=always",
76+
"coverage": "APP_ENV=testing XDEBUG_MODE=coverage co-phpunit --prepend test/bootstrap.php --colors=always --coverage-html .phpunit.cache/coverage",
7677
"cs-fix": "php-cs-fixer fix $1",
7778
"analyse": "phpstan analyse --memory-limit 300M",
7879
"start": [

‎backend/docker/Dockerfile‎

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM hyperf/hyperf:8.3-alpine-v3.19-swoole
1+
FROM hyperf/hyperf:8.3-alpine-v3.19-swoole@sha256:27243bfb6fa3281c1c2e65327913a1d033528ab62ce5c4f4fc9986a180fb6991
22

33
RUN apk update \
44
&& apk add --no-cache autoconf gcc make g++ linux-headers bash \

‎backend/phpunit.xml.dist‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@
1212
<include>
1313
<directory suffix=".php">./app</directory>
1414
</include>
15+
<exclude>
16+
<directory suffix=".php">./app/Controller</directory>
17+
<directory suffix=".php">./app/Exception/Handler</directory>
18+
<directory suffix=".php">./app/Listener</directory>
19+
<directory suffix=".php">./app/Middleware</directory>
20+
<directory suffix=".php">./app/Repositories</directory>
21+
<directory suffix=".php">./app/Request</directory>
22+
<file>./app/Exception/BusinessException.php</file>
23+
</exclude>
1524
</source>
1625
</phpunit>

‎backend/test/Unit/Dto/LoginInputTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Test\Unit\Dto\Login;
5+
namespace HyperfTest\Unit\Dto;
66

77
use App\Dto\Login\LoginInput;
88
use PHPUnit\Framework\TestCase;

‎backend/test/Unit/Dto/LoginOutputTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Test\Unit\Dto\Login;
5+
namespace HyperfTest\Unit\Dto;
66

77
use App\Dto\Login\LoginOutput;
88
use PHPUnit\Framework\TestCase;

‎docker-compose.yml‎

100644100755
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ services:
1212
- 9501:9501
1313
command: >
1414
sh -c "cp .env.example .env &&
15-
touch database/database.sqlite &&
1615
composer install &&
1716
composer dump-autoload &&
1817
php bin/hyperf.php migrate &&
19-
php bin/hyperf.php server:watch"
18+
php bin/hyperf.php start"
2019
networks:
2120
- flykit
2221
depends_on:
23-
- flykit-db
22+
flykit-db:
23+
condition: service_healthy
24+
stop_signal: SIGTERM
25+
stop_grace_period: 30s
2426

2527
flykit-db:
2628
image: mysql:8.0
@@ -37,6 +39,11 @@ services:
3739
- mysql_data:/var/lib/mysql
3840
networks:
3941
- flykit
42+
healthcheck:
43+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot"]
44+
interval: 5s
45+
timeout: 5s
46+
retries: 5
4047

4148
volumes:
4249
mysql_data:

0 commit comments

Comments
 (0)