gpt4 book ai didi

php - 运行时异常 : Unable to guess the Kernel directory

转载 作者:可可西里 更新时间:2023-10-31 23:36:21 24 4
gpt4 key购买 nike

我正在使用 Symfony 3.4。突然,每当我尝试在/tests 中运行我的测试 (phpunit) 时,我都会收到以下错误:

RuntimeException : Unable to guess the Kernel directory.

我的测试类看起来像:

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);
}
}

这是我的 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>

如有任何帮助,我们将不胜感激。

最佳答案

我想几周前我遇到了完全相同的问题,你能尝试添加 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>

关于php - 运行时异常 : Unable to guess the Kernel directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49305159/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com