function its_write_behavior_should_be_detected() { $infoRecord = array('message' => 'My info message', 'context' => array(), 'level' => Logger::INFO, 'level_name' => Logger::getLevelName(Logger::INFO), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), 'extra' => array()); $this->shouldNotBeLogged(); $this->handle($infoRecord); $this->shouldBeLogged(); $this->reset(); $this->shouldNotBeLogged(); $this->handle($infoRecord); $this->shouldBeLogged(); }
public function testWritingAndFormatting() { $output = $this->getMock('Symfony\\Component\\Console\\Output\\ConsoleOutputInterface'); $output->expects($this->any())->method('getVerbosity')->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)); $output->expects($this->once())->method('write')->with('<info>[16:21:54] app.INFO:</info> My info message' . "\n"); $errorOutput = $this->getMock('Symfony\\Component\\Console\\Output\\OutputInterface'); $errorOutput->expects($this->once())->method('write')->with('<error>[16:21:54] app.ERROR:</error> My error message' . "\n"); $output->expects($this->any())->method('getErrorOutput')->will($this->returnValue($errorOutput)); $handler = new ConsoleHandler(null, false); $handler->setOutput($output); $infoRecord = array('message' => 'My info message', 'context' => array(), 'level' => Logger::INFO, 'level_name' => Logger::getLevelName(Logger::INFO), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), 'extra' => array()); $this->assertTrue($handler->handle($infoRecord), 'The handler finished handling the log as bubble is false.'); $errorRecord = array('message' => 'My error message', 'context' => array(), 'level' => Logger::ERROR, 'level_name' => Logger::getLevelName(Logger::ERROR), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), 'extra' => array()); $this->assertTrue($handler->handle($errorRecord), 'The handler finished handling the log as bubble is false.'); }