【问题标题】:Calling Command from within a WebTestCase从 WebTestCase 中调用命令
【发布时间】:2015-04-06 09:53:04
【问题描述】:

我正在尝试从 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 致命错误:调用 /data/www/symfony/src/Prexem/UserBundle/Tests/Controller/DefaultControllerTest.php 中未定义的方法 MyApplication\MyBundle\Tests\Controller\RoutesTest::getApplication()

【问题讨论】:

    标签: symfony


    【解决方案1】:

    我认为 self::getApplication() 是 WebTestCase 的成员,因为我看到了这个方法的snipplet。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多