I am writing a Zend Framework application and unit testing it with PHPUnit. In general, things are going swimmingly however I have a small, but annoying issue with PHPUnit
If that is all there is to your test than i would assume your tests looks like Matthew described:
class UserControllerTest extends Zend_Test_PHPUnit_ControllerTestCase {
// [...]
public function testSomething()
{
$this->request
->setMethod('POST')
->setPost(array(
'username' => 'foobar',
'password' => 'foobar'
));
$this->editAction();
// assertThatTheRightThingsHappend
}
}
and in that case i don't see any reason why it shouldn't be easy to get 100% Code Coverage.
But yes: It is pretty hard to test Zend Framework Controllers and at some point you either have to try really hard to get all your application logic out of your controllers or just live with it.
The same thing doesn't apply for your models though. Those should be really easy to test, even in a ZF Application.
The purpose that code coverage serves is that it tells you what parts of your code base are not even getting executed. It doesn't tell you what is really tested and can only serve as a "minimum" to get an idea about the quality of your test suite (if you don't use @covers even that might lie to you).
On short: If you have big controllers and an not so easy to change architecture just setting with so and so tested controllers but don't apply the same logic to your models. Nothing in ZF prevents you to properly test those