Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3610574

Browse files
author
Marc Wolf
committed
Update to use compose.yml and integrate PHPUnit with Namespaces
- Rename docker-compose.yml to compose.yml - Add PHPUnit 11.2.1 to composer.json - Add phpunit.xml for PHPUnit configuration - Update README.md with setup instructions for Docker Compose and PHPUnit - Ensure .gitignore includes vendor directory - Adjust GitHub Actions workflow to use compose.yml - Add Example class and corresponding PHPUnit test with App namespace - Update composer.json to include PSR-4 autoloading for App namespace - Ensure Xdebug is configured correctly for code coverage
1 parent 4d92869 commit 3610574

File tree

9 files changed

+42
-5
lines changed

9 files changed

+42
-5
lines changed

‎.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
4747
- name: Run PHPUnit tests
4848
run: |
49-
docker compose exec -T php-fpm ./vendor/bin/phpunit tests
49+
docker compose exec -T php-fpm ./vendor/bin/phpunit --coverage-text --testdox tests
5050
5151
- name: Test Redis
5252
run: |

‎compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121
- ".:/app"
2222
- "./docker/php-fpm/php-overrides.ini:/usr/local/etc/php/conf.d/php-overrides.ini"
2323
environment:
24-
XDEBUG_MODE: "debug"
24+
XDEBUG_MODE: "coverage"
2525

2626
redis:
2727
image: "redis:7.2.5-alpine"

‎composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"require-dev": {
33
"phpunit/phpunit": "^11.2.1"
4+
},
5+
"autoload": {
6+
"psr-4": {
7+
"App\\": "src/"
8+
}
49
}
510
}

‎docker/nginx/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ server {
66

77
access_log /var/log/nginx/app.access.log;
88

9-
root /app/public;
9+
root /app/src/public;
1010
index index.php;
1111

1212
location / {

‎docker/php-fpm/php-overrides.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
upload_max_filesize=100M
22
post_max_size=100M
3-
xdebug.mode=debug
3+
xdebug.mode=coverage
44
xdebug.start_with_request=yes
55
xdebug.client_port=9003
66
xdebug.client_host=host.docker.internal

‎phpunit.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
6+
executionOrder="depends,defects"
7+
colors="true">
8+
<testsuites>
9+
<testsuite name="default">
10+
<directory>tests</directory>
11+
</testsuite>
12+
</testsuites>
13+
<source>
14+
<include>
15+
<directory>src</directory>
16+
</include>
17+
</source>
18+
</phpunit>

‎src/Example.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace App;
5+
6+
class Example
7+
{
8+
public function doSomething()
9+
{
10+
return true;
11+
}
12+
}
File renamed without changes.

‎tests/ExampleTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
declare(strict_types=1);
44

55
use PHPUnit\Framework\TestCase;
6+
use App\Example;
67

78
class ExampleTest extends TestCase
89
{
910
public function testExample()
1011
{
11-
$this->assertTrue(true);
12+
$example = new Example();
13+
$this->assertTrue($example->doSomething());
1214
}
1315
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /