Skip to content

Commit

Permalink
ZF-10526: Zend_Controller_Request_Simple and Zend_Db_Profiler_Firebug…
Browse files Browse the repository at this point in the history
… (revision 23065)
  • Loading branch information
b-durand committed Mar 24, 2011
1 parent 4235f98 commit 7ae1d01
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
5 changes: 5 additions & 0 deletions library/Zend/Wildfire/Channel/HttpHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ public function isReady($forceCheckRequest=false)
return true;
}

// use is_a() instead of 'instanceof' to avoid having to load the class
if (!is_a($this->getRequest(), 'Zend\Controller\Request\Http')) {
return false;
}

return ($this->getResponse()->canSendHeaders()
&& (preg_match_all(
'/\s?FirePHP\/([\.\d]*)\s?/si',
Expand Down
32 changes: 26 additions & 6 deletions tests/Zend/Wildfire/WildfireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace ZendTest\Wildfire;
use Zend\Wildfire\Channel,
Zend\Wildfire\Plugin\FirePhp,
Zend\Controller;
Zend\Controller,
Zend\Controller\Request\Simple as SimpleRequest;

/**
* @category Zend
Expand Down Expand Up @@ -115,13 +116,13 @@ public function testIsReady1()
$this->_request->setUserAgentExtensionEnabled(false);

$this->assertFalse($channel->isReady(true));

$this->_request->setUserAgentExtensionEnabled(true, 'User-Agent');

$this->assertTrue($channel->isReady(true));

$this->_request->setUserAgentExtensionEnabled(true, 'X-FirePHP-Version');

$this->assertTrue($channel->isReady(true));
}

Expand All @@ -138,11 +139,11 @@ public function testIsReady2()
$this->assertFalse($channel->isReady());

$this->_request->setUserAgentExtensionEnabled(true, 'User-Agent');

$this->assertTrue($channel->isReady());

$this->_request->setUserAgentExtensionEnabled(true, 'X-FirePHP-Version');

$this->assertTrue($channel->isReady());
}

Expand Down Expand Up @@ -933,6 +934,25 @@ public function testMaxObjectArrayDepth()
'[{"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) **"}}]]]');
}

/**
* @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!');
}
}

class TestObject1
Expand Down

0 comments on commit 7ae1d01

Please sign in to comment.