It’s sunday and I’m playing with Zend_Test. Here are some basic things that took me time to find out :
Grep simple text in the page :

  1. $this->assertQueryContentContains(‘body’, “your email is invalid”);

Verify unvalid users can not log in :

  1. $this->request->setMethod(‘POST’)
  2. ->setPost(array(
  3. ’email’ => ‘fakeaddress@fakedomain.com’,
  4. ‘password’ => ‘fakepassw’
  5. ));
  6. $this->dispatch(‘/user/login’);
  7. $this->assertNotRedirect();
  8. $this->assertFalse(Zend_Auth::getInstance()->hasIdentity());

The interesting part is the last part :

  1. $this->assertFalse(Zend_Auth::getInstance()->hasIdentity());

And, let’s test a form :

  1. $this->assertQueryCountMin(‘form’, 1);
  2. $this->assertQueryCountMin(‘input[name~=”email”]’, 1);
  3. $this->assertQueryCountMin(‘input[name~=”password”]’, 1);
  4. $this->assertQueryCountMin(‘input[name~=”submit”]’, 1);

Nothing fancy here, only some tips that can only make your discovering of Zend_Test easyer ! Happy testing !