gpt4 book ai didi

symfony - 从 WebTestCase 中调用命令

转载 作者:行者123 更新时间:2023-12-02 15:41:31 25 4
gpt4 key购买 nike

我正在尝试从 WebTestCase 中调用“router:debug”命令来自动验证所有静态路由。

class RoutesTest extends WebTestCase
{
public function setUp()
{
$command = self::getApplication()->find('router:debug');
$input = new ArrayInput(array());
$returnCode = $command->run($input, $output);
if($returnCode == 0) {
var_dump($output);
}
}
}

但是我得到了

PHP Fatal error: Call to undefined method MyApplication\MyBundle\Tests\Controller\RoutesTest::getApplication() in /data/www/symfony/src/Prexem/UserBundle/Tests/Controller/DefaultControllerTest.php

最佳答案

我认为 self::getApplication() 是 WebTestCase 的成员,因为我看到了带有此方法的片段。

但实际上我必须像这样实现它: Best way to create a test database and load fixtures on Symfony 2 WebTestCase?

关于symfony - 从 WebTestCase 中调用命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28362662/

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