我在一个 Symfony 4.4 项目中遇到了一个Panther问题。这个项目有LiipFunctionnalTestBundle
,但是为了测试JS,我也想使用Panther。我已经安装了Panther,在我的composer中,我有"symfony/panther": "^0.8.0"
,我可以用PantherTestCase
扩展我的类,或者用PantherTestCaseTrait
得到Panther和Liip
(根据文档symfony/panther).但是我不确定我的项目初始化了Panther...如果我做一个简单的测试,比如:
<?php
namespace App\Tests\Controller\Social;
use Symfony\Component\Panther\PantherTestCase;
class PantherControllerTest extends PantherTestCase
{
public function test1(): void
{
$client = static::createPantherClient(); // create your panther client
$client->request('GET', '/login');
}
}
我在测试时会收到一条错误消息:
App\Tests\Controller\Social\PantherControllerTest::test1
Symfony\Component\Process\Exception\LogicException: Output has been disabled.
and it target the line with "createPantherClient".
如果我尝试将Liip
与WebTestCase
和Panther组合使用:它一直在工作,直到我想使用Panther中的特定Assert。然后我的IDE显示'assertSelectorIsEnabled'
not found in NewsControllerPantherTest'
。方法createPantherClient
无法识别,因此即使我尝试将localhost和端口放入其中,它也无法工作...
所以,我认为黑豹是在我的项目,但不加载?我在一个Windows PC与Mamp,PHP 7.4.1和Apache。
我已经把标记放在了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="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
>
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
非常感谢你的帮助=)
1条答案
按热度按时间k3fezbri1#
我得到这个错误,因为我们的网站目录是非标准的。(发现通过堆栈跟踪)。
尝试将其放入
.env
(用您使用的dir替换web
):