/** * @covers Robo47_Log_Writer_DoctrineTable::_write */ public function testWriteWithChangedColumnMap() { $mapping = array('message' => 'foo', 'priority' => 'baa', 'category' => 'blub', 'timestamp' => 'baafoo'); $this->_writer->setTable($this->_table2); $this->_writer->setColumnMap($mapping); $this->assertEquals(0, $this->_table2->count()); $date = date('c'); $event = array('message' => 'Foo', 'priority' => 0, 'category' => 'bla', 'timestamp' => $date); $this->_writer->write($event); $this->assertEquals(1, $this->_table2->count()); $entry = $this->_table2->createQuery()->select()->execute()->getFirst(); $this->assertEquals($event['message'], $entry->foo); $this->assertEquals($event['priority'], $entry->baa); $this->assertEquals($event['category'], $entry->blub); $this->assertEquals($event['timestamp'], $entry->baafoo); }
/** * Construct a Zend_Log driver * * @param array|Zend_Config $config * @return Robo47_Log_Writer_DoctrineTable */ public static function factory($config) { if ($config instanceof Zend_Config) { $config = $config->toArray(); } if (!isset($config['table'])) { $message = 'No table defined for Robo47_Log_Writer_DoctrineTable'; throw new Robo47_Log_Writer_Exception($message); } $writer = new Robo47_Log_Writer_DoctrineTable($config['table']); if (isset($config['columnMap'])) { $writer->setColumnMap($config['columnMap']); } return $writer; }