Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Recipe for PHPUnit 10 #1239

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions phpunit/phpunit/10.0/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SYMFONY_DEPRECATIONS_HELPER does not make sense for PHPUnit 10+ as we want to use the PHPUnit native deprecation system, which is not configured by the env variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate to use native where possible, which I think should as I did understand Sebastian now be for all features Symfony provided in the past via the bridge?

So maybe we should also remove this part:

        <server name="SYMFONY_PHPUNIT_REMOVE" value="" />
        <server name="SYMFONY_PHPUNIT_VERSION" value="10.5" />

And should we remove the phpunit-bridge from the test-pack:

https://github.com/symfony/test-pack/blob/v1.1.0/composer.json#L10

11 changes: 11 additions & 0 deletions phpunit/phpunit/10.0/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"copy-from-recipe": {
".env.test": ".env.test",
"phpunit.dist.xml": "phpunit.dist.xml",
"tests/": "tests/"
},
"gitignore": [
"/phpunit.xml",
"/.phpunit.cache/"
]
}
34 changes: 34 additions & 0 deletions phpunit/phpunit/10.0/phpunit.dist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
<server name="SYMFONY_PHPUNIT_VERSION" value="10.5" />
</php>

<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not configure the deprecation reporting in a way matching the reporting convention used in symfony/deprecation-contracts. See https://github.com/symfony/demo/pull/1549/files#diff-e35810879ec42bdd81797b3ccb72f6de28a8b4a0e3bfdba43183e133e866b892R25-R37 for the necessary configuration.

<include>
<directory>src</directory>
</include>
</source>

<extensions>
</extensions>
</phpunit>
9 changes: 9 additions & 0 deletions phpunit/phpunit/10.0/tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__).'/vendor/autoload.php';

if (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}
4 changes: 1 addition & 3 deletions phpunit/phpunit/4.7/tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

require dirname(__DIR__).'/vendor/autoload.php';

if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
require dirname(__DIR__).'/config/bootstrap.php';
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
if (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}
4 changes: 1 addition & 3 deletions phpunit/phpunit/9.3/tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

require dirname(__DIR__).'/vendor/autoload.php';

if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
require dirname(__DIR__).'/config/bootstrap.php';
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
if (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}
4 changes: 1 addition & 3 deletions phpunit/phpunit/9.6/tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

require dirname(__DIR__).'/vendor/autoload.php';

if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
require dirname(__DIR__).'/config/bootstrap.php';
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
if (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}
14 changes: 14 additions & 0 deletions symfony/panther/1.0/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@
"content": " <extension class=\"Symfony\\Component\\Panther\\ServerExtension\" />",
"position": "after_target",
"target": "<extensions>",
"warn_if_missing": false
Copy link
Contributor Author

@alexander-schranz alexander-schranz Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by renaming the phpunit.xml.dist to phpunit.dist.xml we also have the advantages that this recipe is compatible so with phpunit 9 recipe and phpunit 10 recipe

},
{
"file": "phpunit.dist.xml",
"content": " <bootstrap class=\"Symfony\\Component\\Panther\\ServerExtension\" />",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panther alreadys supports PHPUnit 10: symfony/panther#589

"position": "after_target",
"target": "<extensions>",
"warn_if_missing": false
},
{
"file": ".env.test",
"content": "PANTHER_APP_ENV=panther\nPANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots",
"position": "after_target",
"target": "SYMFONY_DEPRECATIONS_HELPER=999999",
"warn_if_missing": true
}
]
Expand Down
Loading