Bab*_*nah 5 php phpunit symfony symfony-3.4
我正在使用Symfony 3.4。突然,每当我尝试在/ tests中运行测试(phpunit)时,都会出现以下错误:
RuntimeException : Unable to guess the Kernel directory.
Run Code Online (Sandbox Code Playgroud)
我的测试课看起来像:
class PaymentCreditTest extends KernelTestCase
{
/** @var PaymentRepository */
public $paymentRepository;
/**
* {@inheritDoc}
*/
protected function setUp()
{
$this->paymentRepository = self::bootKernel()->getContainer()->get('chaku.repository.payment');
}
public function test_canRetrieveDeadFreightNetAmount()
{
/** @var Payment $payment */
$payment = $this->paymentRepository->findOneBy(['id' => 1000002]);
// just to see payment object
dump($payment);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的phpunit.xml.dist的样子:
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="app/autoload.php">
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_CLASS" value="AppKernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
<exclude>
<directory>src/*Bundle/Resources</directory>
<directory>src/*/*Bundle/Resources</directory>
<directory>src/*/Bundle/*Bundle/Resources</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激。
小智 2
我想几周前我遇到了完全相同的问题,您可以尝试添加KERNEL_DIR:
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="KERNEL_DIR" value="app/" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2343 次 |
| 最近记录: |