2011年1月22日星期六

[fw-mvc] How do I clear a request in a phpunit test ?

I have a very strange behavior unit testing (note my code works normally though) :

I login through a POST request :

$this->request->setPost(array(
'email' => $this->TestUserEmail,
'password' => $this->TestUserPassword,
));
$this->dispatch('/user/login');
$this->assertRedirect;
$this->assertTrue(Zend_Auth::getInstance()->hasIdentity());

Then send a GET request (to a REST controller) :

$this->request->setMethod('GET');
$this->dispatch('/test/167);
$this->assertAction('index');

I log the request on the GET function of the REST controller like this :

$logger = Zend_Registry::get('logger');
$logger->notice("RECEIVED GET REQUEST : ". print_r($params, true) . "query : " . print_r($this->_request->getParams(), true));

And I get this :

2011-01-21T10:23:17+00:00 NOTICE (5): RECEIVED GET REQUEST : Array
(
[id] => 167
[email] => unittest@test.net
[password] => test
)
query : Array
(
[controller] => jrs
[action] => index
[module] => default
[id] => 167
[table] => test
[email] => unittest@test.net
[password] => test
)

So the problem is that the login data is persistent. I've search everywhere I could but I can't find a way to clear this data. Anyone knows how to do this ?
Thanks !Z.


--
My dojo & zend framework experience, the good, the bad with code samples ;-)

http://practicalphpajax.wordpress.com/

没有评论: