PHPUnit and Zend Framework - Code Coverage redeclares included classes

2 messages Options
Embed this post
Permalink
jingram

PHPUnit and Zend Framework - Code Coverage redeclares included classes

Reply Threaded More More options
Print post
Permalink
When using code coverage, from what I understand, files that I have selected in my white list are iterated through and 'include(d)_once' by PHPUnit. Therefore, if I include, say, my 'application' folder in the white list, the idea is that PHPUnit will search through it and compare it to what tests I have - if there are areas that are not covered, it will report this in code coverage.



However, this can result in multiple inclusions of files and subsequently redeclaration of classes which is a fatal error.



The flow is like this (remember it's under the Zend Framework):



1. Run phpunit and tell it to run some tests given my bootstrap file.

2. The bootstrap does autoloading, includes my models, controllers, etc.

3. Once bootstrapped, the code coverage in PHPUnit iterates through my project folder (I specified 'application' on my white list) and includes all those files again. It fails when it gets to the first file that it has already included (in this case it is 'application/models/Default_Model_Application.php')



Note that the bootstrap is needed to actually run the tests.



I'm happy to provide code, but first I thought maybe there were some suggestions for how to work around this? Or maybe I have something set up wrong.





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Tomas Mysik

Re: PHPUnit and Zend Framework - Code Coverage redeclares included classes

Reply Threaded More More options
Print post
Permalink
Hi,

Dne neděle 25 října 2009 11:00:38 jingram napsal(a):
> When using code coverage, from what I understand, files that I have
>  selected in my white list are iterated through and 'include(d)_once' by
>  PHPUnit. Therefore, if I include, say, my 'application' folder in the
>  white list, the idea is that PHPUnit will search through it and compare it
>  to what tests I have - if there are areas that are not covered, it will
>  report this in code coverage.

please notice that the code coverage is generated by PHPUnit directly, so I'm
not sure whether this can be fixed on NetBeans' side. We will see.

> I'm happy to provide code, but first I thought maybe there were some
>  suggestions for how to work around this? Or maybe I have something set up
>  wrong.

Please, do so - create a new issue [1], provide exact steps to reproduce and
ideally attach a sample project.

Thanks a lot,
Tomas
[1] http://www.netbeans.org/community/issues
--
Tomas Mysik
[hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]