0

我正在编写一些单元测试,需要在单元测试中调用一些命令才能创建测试数据库。但是,当我调用该命令时,它会将通知转储到屏幕上。有没有办法关闭它?我试图执行 --quiet,但它不会抑制通知。

$this->runConsole("doctrine:mongodb:schema:create", array("-q"=> null,"--env" => "test"));    

……

protected function runConsole($command, Array $options = array())
{
    $options = array_merge($options, array('command' => $command));

    return $this->_application->run(new \Symfony\Component\Console\Input\ArrayInput($options));
}

我收到的通知:

[2013-02-07 16:24:43] doctrine.INFO: MongoDB query: {"deleteIndexes":true,"db":"xxxxxx","collection":"xxxxxx} [] []
[2013-02-07 16:24:43] doctrine.INFO: MongoDB query: {"deleteIndexes":true,"db":"xxxxxx","collection":"xxxxxx"} [] []
[2013-02-07 16:24:43] doctrine.INFO: MongoDB query: {"deleteIndexes":true,"db":"xxxxxx","collection":"xxxxxx"} [] []
4

2 回答 2

0

我在 app/config 目录中添加了一个 config_test.yml 并添加了这些行(从我的 config_dev.yml 复制):

monolog:
    handlers:
       main:
           type:  stream
           path:  "%kernel.logs_dir%/%kernel.environment%.log"
           level: debug
       firephp:
           type:  firephp
           level: info
于 2013-02-08T17:04:04.453 回答
0

用于CommandTester测试您的命令。你可以在这里读更多关于它的内容:

http://symfony.com/doc/current/components/console/introduction.html#testing-commands

于 2013-02-07T18:15:53.920 回答