Zend_Test_PHPUnit provides a TestCase for MVC
applications that contains assertions for testing against a variety of
responsibilities. Probably the easiest way to understand what it can do
is to see an example.
Example 937. Application Login TestCase example
The following is a simple test case for a
UserController to verify several things:
The login form should be displayed to non-authenticated users.
When a user logs in, they should be redirected to their profile page, and that profile page should show relevant information.
This particular example assumes a few things. First, we're moving most of our bootstrapping to a plugin. This simplifies setup of the test case as it allows us to specify our environment succinctly, and also allows us to bootstrap the application in a single line. Also, our particular example is assuming that autoloading is setup so we do not need to worry about requiring the appropriate classes (such as the correct controller, plugin, etc).
class UserControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
public function setUp()
$this->bootstrap = array($this, 'appBootstrap');
public function appBootstrap()
public function testCallWithoutActionShouldPullFromIndexAction()
public function testIndexActionShouldContainLoginForm()
public function testValidLoginShouldGoToProfilePage()
'username' => 'foobar',
'password' => 'foobar'
$this->assertQueryContentContains('h2', 'User: foobar');
This example could be written somewhat simpler -- not all the assertions shown are necessary, and are provided for illustration purposes only. Hopefully, it shows how simple it can be to test your applications.