-
Hi :) I have a very weird behavior with sail / phpunit and coverage.
When running locally without docker, Sail version : 1.13.4 My docker-compose.yml # For more information: https://laravel.com/docs/sail
version: '3'
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.1
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.1/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
- 3000:3000
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-coverage}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- pgsql
mailhog:
image: 'mailhog/mailhog'
ports:
- '8025:8025'
networks:
- sail
pgsql:
image: 'postgres:13'
ports:
- '${FORWARD_DB_PORT:-5432}:5432'
environment:
PGPASSWORD: '${DB_PASSWORD:-secret}'
POSTGRES_DB: '${DB_DATABASE}'
POSTGRES_USER: '${DB_USERNAME}'
POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
volumes:
- 'sailpgsql:/var/lib/postgresql/data'
networks:
- sail
healthcheck:
test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"]
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sailpgsql:
driver: local <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
<env name="XDEBUG_MODE" value="coverage"/>
</php>
</phpunit> What’s infuriating, is that it works well on a new project… So I guess I’ve something wrong, but what? Any help would be much appreciated, it drives my crazy! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
@gorghoa according to documentation and your The Just remember to stop and start again the application after doing this ( |
Beta Was this translation helpful? Give feedback.
-
Ok, for the record, we finally swapped xdebug for pcov, and coverage now works as expected. Driving me mad to not understand the issue, but, 🤷 … We added this to the php.ini: pcov.enabled = 1
pcov.directory=/var/www/html/app And disabled xdebug by commenting out the env vars |
Beta Was this translation helpful? Give feedback.
Ok, for the record, we finally swapped xdebug for pcov, and coverage now works as expected.
Driving me mad to not understand the issue, but, 🤷 …
We added this to the php.ini:
And disabled xdebug by commenting out the env vars
XDEBUG_MODE
andXDEBUG_CONFIG