/** * Constructor * @return void */ protected function __construct() { $this->_channel = Wildfire\Channel\HttpHeaders::getInstance(); $this->_channel->getProtocol(self::PROTOCOL_URI)->registerPlugin($this); }
/** * @group ZF-6395 */ public function testNoQueriesAfterFiltering() { $channel = Channel\HttpHeaders::getInstance(); $protocol = $channel->getProtocol(FirePhp\FirePhp::PROTOCOL_URI); $profiler = $this->_profiler->setEnabled(true); $profiler->setFilterQueryType(Profiler::INSERT | Profiler::UPDATE); $this->_db->fetchAll('select * from foo'); Channel\HttpHeaders::getInstance()->flush(); $messages = $protocol->getMessages(); $this->assertFalse($messages); }
/** * @group ZF-10526 */ public function testNonHTTPRequest() { $this->_request = new SimpleRequest(); $this->_response = new Response(); $channel = Channel\HttpHeaders::getInstance(); $channel->setRequest($this->_request); $channel->setResponse($this->_response); // this should not fail with: PHP Fatal error: Call to undefined method Zend_Controller_Request_Simple::getHeader() $this->assertFalse($channel->isReady()); // this should not fail with: PHP Fatal error: Call to undefined method Zend_Controller_Request_Simple::getHeader() $firephp = FirePhp::getInstance(); $firephp->send('This is a log message!'); }
/** * @group ZF-4934 */ public function testAdvancedLogging() { FirePhp::getInstance()->setOption('maxTraceDepth',0); $message = 'This is a log message!'; $label = 'Test Label'; $table = array( 'Summary line for the table', array( array('Column 1', 'Column 2'), array('Row 1 c 1',' Row 1 c 2'), array('Row 2 c 1',' Row 2 c 2') ) ); $this->_logger->addPriority('TRACE', 8); $this->_logger->addPriority('TABLE', 9); $this->_writer->setPriorityStyle(8, 'TRACE'); $this->_writer->setPriorityStyle(9, 'TABLE'); $this->_logger->trace($message); $this->_logger->table($table); try { throw new \Exception('Test Exception'); } catch (\Exception $e) { $this->_logger->err($e); } try { FirePhp::send($message, $label, 'UNKNOWN'); $this->fail('Should not be able to log with undefined log style'); } catch (\Zend\Wildfire\Plugin\Exception\UnexpectedValueException $e) { // success } $channel = Channel\HttpHeaders::getInstance(); $protocol = $channel->getProtocol(FirePhp::PROTOCOL_URI); $messages = array( FirePhp::STRUCTURE_URI_FIREBUGCONSOLE => array( FirePhp::PLUGIN_URI => array( 1 => '[{"Type":"TABLE"},["Summary line for the table",[["Column 1","Column 2"],["Row 1 c 1"," Row 1 c 2"],["Row 2 c 1"," Row 2 c 2"]]]]' ))); $qued_messages = $protocol->getMessages(); unset($qued_messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI][0]); unset($qued_messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI][2]); $this->assertEquals(serialize($qued_messages), serialize($messages)); }
/** * @group ZF-10537 */ public function testFileLineOffsets() { $this->_setupWithoutFrontController(); $firephp = FirePhp::getInstance(); $channel = Channel\HttpHeaders::getInstance(); $protocol = $channel->getProtocol(FirePhp::PROTOCOL_URI); $firephp->setOption('includeLineNumbers', true); $firephp->setOption('maxTraceDepth', 0); $lines = array(); // NOTE: Do NOT separate the following pairs otherwise the line numbers will not match for the test // Message number: 1 $lines[] = __LINE__+1; $firephp->send('Hello World'); // Message number: 2 $lines[] = __LINE__+1; $firephp->send('Hello World', null, 'TRACE'); // Message number: 3 $table = array('Summary line for the table', array( array('Column 1', 'Column 2'), array('Row 1 c 1',' Row 1 c 2'), array('Row 2 c 1',' Row 2 c 2') ) ); $lines[] = __LINE__+1; $firephp->send($table, null, 'TABLE'); $messages = $protocol->getMessages(); $messages = $messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI]; for( $i=0 ; $i<sizeof($messages) ; $i++ ) { if(!preg_match_all('/WildfireTest\.php","Line":' . $lines[$i] . '/', $messages[$i], $m)) { $this->fail("File and line does not match for message number: " . ($i+1)); } } }
/** * @group ZF-10537 */ public function testFileLineOffsets() { $firephp = FirePhp::getInstance(); $channel = Channel\HttpHeaders::getInstance(); $protocol = $channel->getProtocol(FirePhp::PROTOCOL_URI); $firephp->setOption('includeLineNumbers', true); $firephp->setOption('maxTraceDepth', 0); $lines = array(); // NOTE: Do NOT separate the following pairs otherwise the line numbers will not match for the test // Message number: 1 $lines[] = __LINE__ + 1; $this->_logger->log('Hello World', Logger::INFO); // Message number: 2 $this->_logger->addPriority('TRACE', 8); $this->_writer->setPriorityStyle(8, 'TRACE'); $lines[] = __LINE__ + 1; $this->_logger->trace('Trace to here'); // Message number: 3 $this->_logger->addPriority('TABLE', 9); $this->_writer->setPriorityStyle(9, 'TABLE'); $table = array('Summary line for the table', array(array('Column 1', 'Column 2'), array('Row 1 c 1', ' Row 1 c 2'), array('Row 2 c 1', ' Row 2 c 2'))); $lines[] = __LINE__ + 1; $this->_logger->table($table); // Message number: 4 $lines[] = __LINE__ + 1; $this->_logger->info('Hello World'); $messages = $protocol->getMessages(); $messages = $messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI]; for ($i = 0; $i < count($messages); $i++) { if (!preg_match_all('/FirebugTest\\.php","Line":' . $lines[$i] . '/', $messages[$i], $m)) { $this->fail("File and line does not match for message number: " . ($i + 1)); } } }
/** * @group ZF-5540 */ public function testMaxObjectArrayDepth() { $this->_setupWithoutFrontController(); $firephp = FirePhp::getInstance(); $channel = Channel\HttpHeaders::getInstance(); $protocol = $channel->getProtocol(FirePhp::PROTOCOL_URI); $firephp->setOption('maxObjectDepth', 2); $firephp->setOption('maxArrayDepth', 1); $obj = new TestObject3(); $obj->testArray = array('val1', array('val2', array('Hello World'))); $obj->child = clone $obj; $obj->child->child = clone $obj; $firephp->send($obj); $table = array(); $table[] = array('Col1', 'Col2'); $table[] = array($obj, $obj); $firephp->send($table, 'Label', FirePhp::TABLE); $messages = $protocol->getMessages(); $message = $messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI][0]; $this->assertEquals($message, '[{"Type":"LOG"},{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":"** Max Object Depth (2) **"}}]'); $message = $messages[FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][FirePhp::PLUGIN_URI][1]; $this->assertEquals($message, '[{"Type":"TABLE","Label":"Label"},[["Col1","Col2"],[{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":"** Max Object Depth (2) **"}},{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":{"__className":"ZendTest\\\\Wildfire\\\\TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":"** Max Object Depth (2) **"}}]]]'); }