这是我的测试文件:
<?php
// src/tests/UserActionsTest.php
namespace App\Tests;
use Symfony\Component\Panther\PantherTestCase;
class UserActionsTest extends PantherTestCase {
/**
* An user can subscribe on the Blog
*/
public function testRegistration(): void {
$client = static::createPantherClient();
$crawler = $client->request('GET', '/subscribe');
// This form is generated in JavaScript
$client->waitFor('#subscribe-form');
// Form submission
$client->submitForm('Create the account', [
'username' => 'zozor',
'password' => 'ZoZ0rIsHome',
]);
// User rediction newly subscribed to the homepage
$this->assertSame(self::$baseUrl . '/', $client->getCurrentURL());
// Success notification in JavaScript
$client->waitFor('#success-message');
$this->assertSame('Welcome on the Zozor blog', $crawler->filter('#success-message ol li:first-child')->text());
// The user is well authenticatd
$this->assertSame('Zozor', $crawler->filter('#user-profile span:first-child')->text());
}
}
当我运行命令时:
PANTHER_NO_HEADLESS=1 ./vendor/bin/simple-phpunit --filter="UserActionsTest"
这给了我一个错误:
1) App\Tests\UserActionsTest::testRegistration
Facebook\WebDriver\Exception\SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 85
./vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:125
./vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:371
./vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:136
./vendor/symfony/panther/src/ProcessManager/ChromeManager.php:67
./vendor/symfony/panther/src/Client.php:98
./vendor/symfony/panther/src/Client.php:365
./vendor/symfony/panther/src/Client.php:254
./tests/UserActionsTest.php:13
我在 DuckDuckGo 上进行了搜索,但与 Symfony、PHPUnit 甚至 PHP 语言无关。
我倾向于版本问题,这是我的composer.json:
{
// ...
"require": {
"php": ">=7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "1.11.99.1",
"doctrine/annotations": "^1.11",
"doctrine/doctrine-bundle": "^2.2",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.7",
"sensio/framework-extra-bundle": "^5.6",
"symfony/apache-pack": "^1.0",
"symfony/asset": "4.4.*",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/flex": "^1.3.1",
"symfony/form": "4.4.*",
"symfony/framework-bundle": "4.4.*",
"symfony/panther": "^0.8.0",
"symfony/security-bundle": "4.4.*",
"symfony/validator": "4.4.*",
"symfony/yaml": "4.4.*"
},
"require-dev": {
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.58",
"phpstan/phpstan-beberlei-assert": "^0.12.3",
"symfony/browser-kit": "4.4.*",
"symfony/css-selector": "4.4.*",
"symfony/maker-bundle": "^1.24",
"symfony/phpunit-bridge": "^5.2",
"symfony/stopwatch": "^4.4",
"symfony/twig-bundle": "^4.4",
"symfony/web-profiler-bundle": "^4.4"
},
// ...
}
这是我的 phpunit.xml.dist:
<?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="bin/.phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<env name="KERNEL_CLASS" value="App\Kernel" />
<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="7.5" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="" />
<!-- ###+ doctrine/doctrine-bundle ### -->
<env name="DATABASE_URL" value="mysql://:@localhost:33060/" />
<!-- ###- doctrine/doctrine-bundle ### -->
<!-- ###+ symfony/swiftmailer-bundle ### -->
<env name="MAILER_URL" value="null://localhost" />
<!-- ###- symfony/swiftmailer-bundle ### -->
<!-- ###+ symfony/framework-bundle ### -->
<env name="APP_DEBUG" value="1" />
<env name="APP_SECRET" value="" />
<!-- ###- symfony/framework-bundle ### -->
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
<extensions>
<!-- It begins a database transaction before every testcase and rolls it back after
the test finished, so tests can manipulate the database without affecting other tests
<extension class="\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" /> -->
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
</phpunit>
如果我按照 symfony/panther 的建议添加该行:
<listener class="Symfony\Component\Panther\ServerListener" />
这给了我错误:
1x: The "Symfony\Component\Panther\ServerListener" class is deprecated since Panther 0.6, use "Symfony\Component\Panther\ServerExtension" instead.
但是使用 Symfony\Component\Panther\ServerExtension 它给了我错误:
Class "Symfony\Component\Panther\ServerExtension" does not implement the PHPUnit\Framework\TestListener interface
预先感谢您的帮助。