I'm using PHPunit to test our Zend Framework project and it works allright but i'm not getting coverage om my action methods in my controllers.
Although I get coverage in number off lines of code but I want to have coverage on the functions/methods.
I see a lot of examples on the internet where they just do it like this:
class IndexTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function testIndexAction() {
$this->dispatch('/');
$this->assertController('index');
$this->assertAction('index');
$this->assertXpath("//form[@action = '/index']");
}
}
Which should work even if I look to this example from Jon:
http://www.zendcasts.com/unit-testing-with-the-zend-framework-with-zend_test-and-phpunit/2009/06/
http://code.google.com/p/zendcasts/source/browse/#svn/trunk/zc25-unit-testing
I'm doing it almost the exact way but it's not giving me any percentage of code coverage in functions, except for the init() function but I think that one is automaticly ignored by Zend Controller testcase.
I'm I doing something stupid or doesn't PHPUnit reconize it's calling this action? Using PHPUnit 3.5.14 and Zend Framework 1.11.x
To get code coverage for a specific function from PHPunit you need to make sure every line of your function is called by your tests, so that every possible situation is taken care of and tested.