(on Saturday, 22 January 2011, 09:44 AM +0100):
>
> 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');
You need to reset the request and response objects between requests:
$this->resetRequest()
->resetResponse();
Better is to simply manipulate Zend_Auth directly, which allows you to
pretend a previous request had been made; for an example, read the
following blog post:
http://www.littlehart.net/atthekeyboard/2010/06/03/testing-controllers-hiding-behind-zend_auth/
> 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/
>
>
>
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
没有评论:
发表评论