panther
panther copied to clipboard
<bootstrap> instead of <extension> expected in phpunit 10.4 configuration
Hi, when upgrading to phpunit 10.4, I get a warning:
1) Test results may not be as expected because the XML configuration file did not pass validation:
Line 21:
- Element 'extension': This element is not expected. Expected is ( bootstrap ).
This is my configuration:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension"/>
</extensions>
</phpunit>
But if I replace the extension by the bootstrap xml element as expected, my whole test suite crashes:
2) Exception in third-party event subscriber: Too few arguments to function Symfony\Component\Panther\ServerExtensionLegacy::executeBeforeTest(), 0 passed in /home/runner/work/saas/saas/vendor/symfony/panther/src/ServerExtension.php on line 81 and exactly 1 expected
#0 /home/runner/work/saas/saas/vendor/symfony/panther/src/ServerExtension.php(81): Symfony\Component\Panther\ServerExtensionLegacy->executeBeforeTest()
#1 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/Event/Dispatcher/DirectDispatcher.php(100): PHPUnit\Event\Test\PreparationStartedSubscriber@anonymous->notify()
#2 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/Event/Dispatcher/DeferringDispatcher.php(45): PHPUnit\Event\DirectDispatcher->dispatch()
#3 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/Event/Emitter/DispatchingEmitter.php(305): PHPUnit\Event\DeferringDispatcher->dispatch()
#4 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/Framework/TestCase.php(619): PHPUnit\Event\DispatchingEmitter->testPreparationStarted()
#5 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/Framework/TestRunner.php(103): PHPUnit\Framework\TestCase->runBare()
#6 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/Framework/TestCase.php(489): PHPUnit\Framework\TestRunner->run()
#7 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/Framework/TestSuite.php(340): PHPUnit\Framework\TestCase->run()
#8 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/Framework/TestSuite.php(340): PHPUnit\Framework\TestSuite->run()
#9 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/Framework/TestSuite.php([34](https://github.com/windoo/saas/actions/runs/7035095748/job/19144674893#step:15:35)0): PHPUnit\Framework\TestSuite->run()
#10 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(63): PHPUnit\Framework\TestSuite->run()
#11 /home/runner/work/saas/saas/vendor/phpunit/phpunit/src/TextUI/Application.php(189): PHPUnit\TextUI\TestRunner->run()
#12 /home/runner/work/saas/saas/vendor/phpunit/phpunit/phpunit(99): PHPUnit\TextUI\Application->run()
#13 {main}
I believe it resembles https://github.com/symfony/panther/issues/608 but I can't find any mention of this "bootstrap" element in the configuration, the docs in this case are not up-to-date with the requirements of phpunit it seems.
Package versions:
- Globally SF 6.3
- Panther 2.1.0
- PHPUnit 10.4.2
This seems to be related to #608 and has already been fixed with #609, but didn't make it into a release so far.
I had the same error and can confirm that changing it to <bootstrap class="Symfony\Component\Panther\ServerExtension"/>
and requirering a develement version with "symfony/panther": "dev-main#077a68c"
via composer solves the issue.
Thanks, it works indeed. The docs of Symfony Panther are not up-to-date, so I thank this issue is valid even from the configuration standpoint.
@dunglas do you have an ETA on the next release for this package ? This is a blocking bug for any configuration as far as I understand.
Release 2.1.1 has been made by @dunglas on Dec 3rd. This solves the issue:
With 2.1.0:
$ composer test
> phpunit
PHPUnit 10.5.0 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.13
Configuration: /var/www/phpunit.xml.dist
............ 12 / 12 (100%)
Time: 00:10.290, Memory: 30.00 MB
There were 24 PHPUnit test runner warnings:
1) Exception in third-party event subscriber: Too few arguments to function Symfony\Component\Panther\ServerExtensionLegacy::executeBeforeTest(), 0 passed in /var/www/vendor/symfony/panther/src/ServerExtension.php on line 81 and exactly 1 expected
[...]
With 2.1.1:
$ composer update symfony/panther
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
- Upgrading symfony/panther (v2.1.0 => v2.1.1)
Writing lock file
[...]
$ composer test
> phpunit
PHPUnit 10.5.0 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.13
Configuration: /var/www/phpunit.xml.dist
............ 12 / 12 (100%)
Time: 00:09.515, Memory: 30.00 MB
OK (12 tests, 31 assertions)
This ticket can be closed.