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

[phpunit] limited support for PHPUnit 10 #1174

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions phpunit/phpunit/10.0/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
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.xml.dist": "phpunit.xml.dist",
"tests/": "tests/"
},
"gitignore": [
"/phpunit.xml",
".phpunit.result.cache"
]
}
37 changes: 37 additions & 0 deletions phpunit/phpunit/10.0/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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"
>
<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.0" />
</php>

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

<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>

<!-- Run `composer require symfony/panther` before enabling this extension -->
<!--
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
-->
</phpunit>
11 changes: 11 additions & 0 deletions phpunit/phpunit/10.0/tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Symfony\Component\Dotenv\Dotenv;

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')) {
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}
12 changes: 9 additions & 3 deletions symfony/phpunit-bridge/5.3/bin/phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ if (!ini_get('date.timezone')) {
}

if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
if (class_exists(PHPUnit\TextUI\Command::class)) {
// PHPUnit < 9.x
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
} else {
// PHPUnit >= 10.0
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
Copy link
Member

Choose a reason for hiding this comment

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

the bridge is not compatible with phpunit 10.
I'd suggest removing that part for now at least

Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering about a 3rd option :).

Is there a reason why we called PHPUnit\TextUI\Command::main() for PHPUnit 9.5 vs requiring the executable? Could this new code be used in ALL cases?

the bridge is not compatible with phpunit 10.

I understand this... but since you CAN easily install phpunit-bridge and PHPUnit 10, if there is a straightforward way to get this file working today, why wait until tomorrow to do it? :)

Choose a reason for hiding this comment

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

the bridge is not compatible with phpunit 10.

I would argue that at all times the phpunit-bridge should preventively declare a conflict with future major versions of PHPunit until tested/adapted, it already declares some:

    "conflict": {
        "phpunit/phpunit": "<7.5|9.1.2"
    },

I'd suggest adding |>=11 once v10 support is implemented (won't make any difference now as Composer will just install the older version not declaring the conflict).

Right now running symfony new test followed by composer req symfony/phpunit-bridge phpunit/phpunit on a new project will create a broken project.

}
} else {
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
Expand Down