symfony - 从 WebTestCase 中调用命令

标签 symfony

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

相关文章:

symfony - 用作 Symfony 参数的非标量 ENV

php - symfony 通知 : Undefined index: username

symfony - 错误代码 1 缓存 :clear during composer require

php - 如何限制 Doctrine2 中的关联实体结果?

forms - 如何在表单中仅加载 OneToMany 关联的子集?

php - 如何编写可以将数据重新分配到新表中的 Doctrine 迁移

php - Apache 和 Symfony date.timezone 错误

php - Symfony 的主要 config.yml 中的可选参数值

symfony - 更新到 Symfony 2.6 后出现“必须定义参数 "debug.error_handler.throw_at"”错误

Symfony3+PHP单元。如何禁用控制台中的调试日志?