/**
  * Test logging to both ConsoleLog and FileLog
  */
 public function testCombinedLogWriting()
 {
     TestCakeLog::config('test_console_log', array('engine' => 'TestConsoleLog'));
     $mock = $this->getMock('TestConsoleLog', array('write'), array(array('types' => 'error')));
     TestCakeLog::replace('test_console_log', $mock);
     // log to both file and console
     $message = 'Test error message';
     $mock->expects($this->once())->method('write');
     TestCakeLog::write(LOG_ERR, $message);
     $this->assertTrue(file_exists(LOGS . 'error.log'), 'error.log missing');
     $logOutput = file_get_contents(LOGS . 'error.log');
     $this->assertContains($message, $logOutput);
     // TestConsoleLog is only interested in `error` type
     $message = 'Test info message';
     $mock->expects($this->never())->method('write');
     TestCakeLog::write(LOG_INFO, $message);
     // checks that output is correctly written in the correct logfile
     $this->assertTrue(file_exists(LOGS . 'error.log'), 'error.log missing');
     $this->assertTrue(file_exists(LOGS . 'debug.log'), 'debug.log missing');
     $logOutput = file_get_contents(LOGS . 'error.log');
     $this->assertNotContains($message, $logOutput);
     $logOutput = file_get_contents(LOGS . 'debug.log');
     $this->assertContains($message, $logOutput);
 }