As you say, you want to test actions / controllers, I suppose you are not typing unit tests, but functional / integration tests, i.e. working with Zend_Test and testing through MVC.
Here is the test function I used in the project where I am testing if the login is ok:
public function testLoggingInShouldBeOk() { $this->dispatch('/login/login'); $csrf = $this->_getLoginFormCSRF(); $this->resetResponse(); $this->request->setPost(array( 'login' => 'LOGIN', 'password' => 'PASSWORD', 'csrfLogin' => $csrf, 'ok' => 'Login', )); $this->request->setMethod('POST'); $this->dispatch('/login/login'); $this->assertRedirectTo('/'); $this->assertTrue(Zend_Auth::getInstance()->hasIdentity()); }
Simple: I download the login form, extract the CSRF token, filling out the form and posting it.
Then I can check if I am connected.
In doing so, you can probably extract the login part to call it before each of your tests, which requires a valid user to be registered.
source share