/** * Tests the loggable mixin methods * @return void */ public function testMixinMethods() { $instance = Log::getInstance(); $writer = new Log\Writer\Mock(array('formatter' => array('simple' => array('format' => '%category% - %message%')))); $instance->writers->mock = $writer; $loggable = new LoggableMock(); $loggable->log('Hello world'); $loggable->log(new Log\Entry(array('message' => 'Hello world', 'category' => 'test'))); $entries = $writer->getEntries(); $this->assertEquals('uncategorised - Hello world', $entries[0]); $this->assertEquals('test - Hello world', $entries[1]); }
/** * Tests multiple writers with different formats * @return void */ public function testMultipleWritersDifferentFormat() { $instance = new Log(); $instance->writers->mock1 = new Log\Writer\Mock(array('formatter' => array('simple' => array('format' => '%message%')))); $instance->writers->mock2 = new Log\Writer\Mock(array('formatter' => array('simple' => array('format' => '%pid% - %message%')))); $instance->write('Hello world'); $entries1 = $instance->writers->mock1->getEntries(); $this->assertEquals('Hello world', $entries1[0]); $entries2 = $instance->writers->mock2->getEntries(); $this->assertEquals(getmypid() . ' - Hello world', $entries2[0]); }
/** * Gets the object associated with this mixin * @return \Nimbles\Core\Log */ public function getObject() { return Log::getInstance(); }