Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Bug #17699 Fatal error generating code coverage with PHPUnit 5.3.0RC1
Submitted: 2010-08-13 14:38 UTC
From: konafets Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0a1)
PHP Version: 5.3.2 OS: OSX 10.6
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 17 + 29 = ?

 
 [2010-08-13 14:38 UTC] konafets (Stefano Kowalke)
Description: ------------ I want create a coverage report with phpunit execute this command: Test script: --------------- phpunit --coverage-clover=results/PHPUnit/Clover/clover.xml --verbose /PHP_CodeSniffer/tests/AllTests.php Expected result: ---------------- All tests running without any problems and I get the coverage report. Actual result: -------------- Fatal error: Uncaught exception 'ReflectionException' with message 'Method MySource_Tests_Channels_DisallowSelfActionsUnitTest::DisallowSelfActions() does not exist' in /usr/lib/php/PHP/CodeCoverage/Util.php:218 Stack trace: #0 /usr/lib/php/PHP/CodeCoverage/Util.php(218): ReflectionMethod->__construct('MySource_Tests_...', 'DisallowSelfAct...') #1 /usr/lib/php/PHP/CodeCoverage.php(502): PHP_CodeCoverage_Util::getLinesToBeCovered('MySource_Tests_...', 'DisallowSelfAct...') #2 /usr/lib/php/PHP/CodeCoverage.php(236): PHP_CodeCoverage->applyCoversAnnotationFilter(Array, Object(MySource_Tests_Channels_DisallowSelfActionsUnitTest)) #3 /usr/lib/php/PHPUnit/Framework/TestResult.php(642): PHP_CodeCoverage->append(Array, Object(MySource_Tests_Channels_DisallowSelfActionsUnitTest), Array) #4 /usr/lib/php/PHPUnit/Framework/TestCase.php(599): PHPUnit_Framework_TestResult->run(Object(MySource_Tests_Channels_DisallowSelfActionsUnitTest)) #5 /usr/lib/php/PHPUnit/Framework/TestSuite.php(751): PHPUnit_Framework_TestCase->run(Object(PHPUnit in /usr/lib/php/PHP/CodeCoverage/Util.php on line 218

Comments

 [2010-08-14 06:11 UTC] doconnor (Daniel O'Connor)
Against SVN, there's another fatal error: PHP Fatal error: Call to a member function getFilename() on a non-object in /home/clockwerx/pear/PHP_CodeSniffer/trunk/tests/Standards/AbstractSniffUnitTest.php on line 178
 [2010-08-14 06:15 UTC] doconnor (Daniel O'Connor)
r302198
 [2010-08-14 06:17 UTC] doconnor (Daniel O'Connor)
Stefano, I believe this is resolved in current SVN - barring the other test failures which might be hiding it.
 [2010-08-14 06:17 UTC] doconnor (Daniel O'Connor)
-Assigned To: +Assigned To: squiz
 [2010-08-14 15:51 UTC] konafets (Stefano Kowalke)
Ok, i can confirm the error "PHP Fatal error: Call to a member function getFilename() on a non-object in /home/clockwerx/pear/PHP_CodeSniffer/trunk/tests/Standards/AbstractSniffUnitTest.php on line 178" against the current trunk. This doesn't occur with the latest alpha. But the origin fatal error is still there.
 [2010-08-14 15:54 UTC] konafets (Stefano Kowalke)
I expressed me incorrect: I can reproduce the error you mentioned with the current trunk when I removed the type hint. With the type hint this error is fixed, but my issue is still there.
 [2010-08-16 05:17 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Was actually a problem in SVN only, and caused by new feature to allow standards to contain ignore patterns. Refactored the way the custom testing system checks sniffs and added the generic sniffs back into the test list. All working now.
 [2010-08-17 02:24 UTC] konafets (Stefano Kowalke)
With which version of PHPUnit this works for you? I had update my working directory to latest trunk, but the error is still there. I tried this with PHPUnit 3.4.0 and PHPUnit 3.5.0RC1.
 [2010-08-17 03:10 UTC] squiz (Greg Sherwood)
This is my output: 94:trunk gsherwood$ phpunit tests/AllTests.php PHPUnit 3.4.10 by Sebastian Bergmann. ............................................................ 60 / 233 ............................................................ 120 / 233 ....................SS...................................... 180 / 233 .................S................................... Time: 15 seconds, Memory: 33.00Mb OK, but incomplete or skipped tests! Tests: 233, Assertions: 138, Skipped: 3. I had a slightly older version, so I also updated to 3.4.15 (latest stable) and got exactly the same results.
 [2010-08-17 11:44 UTC] konafets (Stefano Kowalke)
Please try it with the --coverage-clover option: This is the output with PHPUnit 3.5.0RC1, but its the same with 3.4 phpunit --coverage-clover=/Users/sok/Sites/projekte/hudson/jobs/CodeSnifferTYPO3/workspace/results/PHPUnit/Clover/clover.xml --verbose /Users/sok/Downloads/CodeSniffer/tests/AllTests.php Notice: Please no longer include "PHPUnit/Framework.php". in /usr/lib/php/PHPUnit/Framework.php on line 51 PHPUnit 3.5.0RC1 by Sebastian Bergmann. PHP CodeSniffer PHP CodeSniffer Core Core_IsCamelCapsTest ....... Core_ErrorSuppressionTest .... Core_ReportingTest .. Core_Reports_CheckstyleTest . Core_Reports_FullTest . Core_Reports_SummaryTest . Core_Reports_XmlTest . Core_Reports_CsvTest . Core_Reports_EmacsTest . Core_Reports_SourceTest . Core_Reports_SvnblameTest .. Core_Reports_GitblameTest . testGetGitAuthor ......... PHP CodeSniffer Standards Fatal error: Uncaught exception 'ReflectionException' with message 'Method Generic_Tests_Classes_DuplicateClassNameUnitTest::DuplicateClassName() does not exist' in /usr/lib/php/PHP/CodeCoverage/Util.php:218 Stack trace: #0 /usr/lib/php/PHP/CodeCoverage/Util.php(218): ReflectionMethod->__construct('Generic_Tests_C...', 'DuplicateClassN...') #1 /usr/lib/php/PHP/CodeCoverage.php(502): PHP_CodeCoverage_Util::getLinesToBeCovered('Generic_Tests_C...', 'DuplicateClassN...') #2 /usr/lib/php/PHP/CodeCoverage.php(236): PHP_CodeCoverage->applyCoversAnnotationFilter(Array, Object(Generic_Tests_Classes_DuplicateClassNameUnitTest)) #3 /usr/lib/php/PHPUnit/Framework/TestResult.php(642): PHP_CodeCoverage->append(Array, Object(Generic_Tests_Classes_DuplicateClassNameUnitTest), Array) #4 /usr/lib/php/PHPUnit/Framework/TestCase.php(599): PHPUnit_Framework_TestResult->run(Object(Generic_Tests_Classes_DuplicateClassNameUnitTest)) #5 /usr/lib/php/PHPUnit/Framework/TestSuite.php(751): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_Te in /usr/lib/php/PHP/CodeCoverage/Util.php on line 218
 [2010-08-18 04:06 UTC] squiz (Greg Sherwood)
Everything works fine for me from trunk. Here is the full verbose output. 94:trunk gsherwood$ phpunit --coverage-clover=/Users/gsherwood/PHP_CodeSniffer/trunk/clover.xml --verbose tests/AllTests.php PHPUnit 3.4.15 by Sebastian Bergmann. PHP CodeSniffer PHP CodeSniffer Core Core_IsCamelCapsTest ....... Core_ErrorSuppressionTest .... Core_ReportingTest .. Core_Reports_CheckstyleTest . Core_Reports_FullTest . Core_Reports_SummaryTest . Core_Reports_XmlTest . Core_Reports_CsvTest . Core_Reports_EmacsTest . Core_Reports_SourceTest . Core_Reports_SvnblameTest .. Core_Reports_GitblameTest . testGetGitAuthor ......... PHP CodeSniffer Standards ........................................................... .................................................SS........ ...............................................S........... ........................ Time: 01:06, Memory: 68.00Mb There were 3 skipped tests: 1) Squiz_Tests_Debug_JavaScriptLintUnitTest::JavaScriptLint /Users/gsherwood/PHP_CodeSniffer/trunk/tests/Standards/AbstractSniffUnitTest.php:82 /Users/gsherwood/PHP_CodeSniffer/trunk/tests/TestSuite.php:49 2) Squiz_Tests_Debug_JSLintUnitTest::JSLint /Users/gsherwood/PHP_CodeSniffer/trunk/tests/Standards/AbstractSniffUnitTest.php:82 /Users/gsherwood/PHP_CodeSniffer/trunk/tests/TestSuite.php:49 3) Zend_Tests_Debug_CodeAnalyzerUnitTest::CodeAnalyzer /Users/gsherwood/PHP_CodeSniffer/trunk/tests/Standards/AbstractSniffUnitTest.php:82 /Users/gsherwood/PHP_CodeSniffer/trunk/tests/TestSuite.php:49 OK, but incomplete or skipped tests! Tests: 233, Assertions: 138, Skipped: 3. Writing code coverage data to XML file, this may take a moment
 [2010-08-18 10:48 UTC] konafets (Stefano Kowalke)
Thanks for the whole output. I downgrade my phpunit installation to 3.4.15 and now it works. So it seems to be an issue with phpunit 3.5.0RC1. Sebastian Bergman had done a lot of refactoring in this version so I don`t know exactly if the issue is phpcs or phpunit related. What do you think?
 [2010-08-19 08:19 UTC] squiz (Greg Sherwood)
-Summary: Fatal error: Uncaught exception 'ReflectionException' +Summary: Fatal error generating code coverage with PHPUnit 5.3.0RC1
I took a look into this and found there was a change in 3.5.0 to the way code coverage works so that it now requires the name of the unit test to be a real method. So I changed that in the PHPCS test suite and it is working now for me. Change has been committed to SVN.
 [2010-08-19 15:15 UTC] konafets (Stefano Kowalke)
Hey, thanks a lot for your very fast work, guys. For me it works also.