Skip to content

Instantly share code, notes, and snippets.

@nacholibre
Last active December 4, 2024 14:59
Show Gist options
  • Save nacholibre/355c25d9bdde2bf88693472e6fb15a09 to your computer and use it in GitHub Desktop.
Save nacholibre/355c25d9bdde2bf88693472e6fb15a09 to your computer and use it in GitHub Desktop.
Symfony Panther PHPUnit Gitlab CI example
e2e-tests:
stage: Test
image: php:8.1
variables:
PANTHER_APP_ENV: panther_ci
PANTHER_NO_SANDBOX: 1
PANTHER_WEB_SERVER_PORT: 9080
PANTHER_DEVTOOLS: 1
PANTHER_CHROME_ARGUMENTS: '--disable-dev-shm-usage'
PANTHER_ERROR_SCREENSHOT_ATTACH: 1
PANTHER_ERROR_SCREENSHOT: 1
PANTHER_ERROR_SCREENSHOT_DIR: var/error-screenshots
script:
# Install the needed extensions
- apt-get update
- apt-get install -y libxss1 libappindicator1 gnupg ca-certificates
- echo "deb http://deb.debian.org/debian stable main" >> /etc/apt/sources.list
- apt-get update
- apt-get install -y chromium chromium-driver
- chromium --version
- apt-get install -y git unzip libzip-dev libicu-dev mariadb-client libpng-dev libfontconfig1 fontconfig libxrender-dev libfreetype6 libxrender1 zlib1g-dev xvfb
- pecl install xdebug && docker-php-ext-enable xdebug
# Install composer
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Replace env variables with the ones for the CI
- cp .env.test_ci .env.local
# Install composer packages
- composer install --no-scripts
- vendor/bin/bdi detect drivers -vvv
# Run tests.
- php -d memory_limit=1G bin/phpunit --configuration phpunit.xml.panther_ci
artifacts:
paths:
- var/error-screenshots
when: always

Symfony Panther PHPUnit Gitlab CI Example

<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="tests/bootstrap.php">
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
<server name="APP_ENV" value="test_ci"/>
<env name="PANTHER_APP_ENV" value="panther_ci" force="true" />
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="7.5"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<env name="XDEBUG_MODE" value="coverage"/>
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests/E2E</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
</phpunit>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment