我正在尝试从 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/