Hi everyone,

I'm trying to test my ZF-Controllers with phpunit.
The internet (http://www.alexatnet.com/node/12) gave me the following
code to start a request to a given controller/action and then check
the rendered output:

 $front = Zend_Controller_Front::getInstance();
 $request = new
Zend_Controller_Request_Http('http://localhost/main/user/register');
 $response = new Zend_Controller_Response_Http();
 $front->returnResponse(true)->setRequest($request)->setResponse($response);
 $front->dispatch();
 $this->assertContains('</form>', $response->getBody());

My problem is now, that if I run this code twice while testing (for
testing two different controller/actions) all the View's variable's
are still set.
So if my first controller for the url "/main/user/register" sets
$this->view->foo=1, then I can run another request for "/main/image",
and the $this->view->foo variable is still set to "1".

So I think this is, because the Fron-Controller is a
singleton-instance, and there's also only one view instantiated per
frontcontroller?
So  I thought maybe I should reset all those view-variables with
Zend_View::clearVars(), but I have no idea, how I could reach the
current view for example from a phpunit setUp()-method..

Am I already doing something wrong with my frontcontroller-dispatch
code? Or should I really clear those variables out before every
request?
Any help is appreciated!
I'm using th ZF 1.5 RC3

Sincerely,
 Reto

Reply via email to