Example #1
0
 /**
  * Tests the Driver::log method.
  *
  * @return  void
  *
  * @covers  Joomla\Database\DatabaseDriver::log
  * @covers  Joomla\Database\DatabaseDriver::setLogger
  * @since   1.0
  */
 public function testLog()
 {
     $this->logs = array();
     $mockLogger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
     $mockLogger->expects($this->any())->method('log')->willReturnCallback(array($this, 'mockLog'));
     $this->instance->log(Log\LogLevel::DEBUG, 'Debug', array('sql' => true));
     $this->assertEmpty($this->logs, 'Logger not set up yet.');
     // Set the logger and try again.
     $this->instance->setLogger($mockLogger);
     $this->instance->log(Log\LogLevel::DEBUG, 'Debug', array('sql' => true));
     $this->assertEquals(Log\LogLevel::DEBUG, $this->logs[0]['level']);
     $this->assertEquals('Debug', $this->logs[0]['message']);
     $this->assertEquals(array('sql' => true), $this->logs[0]['context']);
 }