PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() #43

Closed
isidromerayo opened this Issue Dec 27, 2011 · 8 comments

Projects

None yet

6 participants

@isidromerayo

Hi,
I try to using PHPUnit Integration, but I have a problem...

PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/share/php/Mockery/Adapter/Phpunit/TestListener.php on line 46
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main($exit = uninitialized) /usr/bin/phpunit:44
PHP 3. PHPUnit_TextUI_Command->run($argv = array (0 => '/usr/bin/phpunit'), $exit = TRUE) /usr/share/php/PHPUnit/TextUI/Command.php:125
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = class PHPUnit_Framework_TestSuite { protected $backupGlobals = NULL; protected $backupStaticAttributes = NULL; protected $name = 'Unit test suite'; protected $groups = array ('nogroup' => array (...)); protected $tests = array (0 => class PHPUnit_Framework_TestSuite { ... }); protected $numTests = 1; protected $testCase = FALSE }, $arguments = array ('listGroups' => FALSE, 'loader' => NULL, 'useDefaultConfiguration' => TRUE, 'configuration' => '/home/imerayo/PhpstormProjects/point-of-sale/tests/phpunit.xml')) /usr/share/php/PHPUnit/TextUI/Command.php:187

I only add to my phpunit.xml

<listeners>
    <listener class="\Mockery\Adapter\Phpunit\TestListener"
              file="Mockery/Adapter/Phpunit/TestListener.php">
    </listener>
</listeners>

My enviroment is

php -v

PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011 18:18:37)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

pear list -c phpunit

Installed packages, channel pear.phpunit.de:

Package Version State
DbUnit 1.1.1 stable
File_Iterator 1.3.0 stable
PHPUnit 3.6.5 stable
PHPUnit_MockObject 1.1.0 stable
PHPUnit_Selenium 1.1.3 stable
PHP_CodeCoverage 1.1.1 stable
PHP_Invoker 1.0.1 stable
PHP_Timer 1.0.2 stable
PHP_TokenStream 1.1.1 stable
Text_Template 1.1.1 beta
phpcpd 1.3.5 stable
phploc 1.6.4 stable
ppw 1.0.4 stable

pear list -c deepend

Installed packages, channel pear.survivethedeepend.com:

Package Version State
Mockery 0.7.1 stable

Sorry but my poor english.
Thanks!

@darlanalves

Same error here, but in another file:
PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/share/php/PHPUnit/Autoload.php on line 64

@viv
viv commented Jan 3, 2012

Hi guys, it looks like you're hitting the same issue I ran in to. Take a look at issue 40 which has a fix. If you take this fix then you'll need to manually exclude Mockery from coverage reports using PHPUnit's config options:

http://www.phpunit.de/manual/3.6/en/appendixes.configuration.html#appendixes.configuration.blacklist-whitelist

@isidromerayo

Hi, I add to blacklist TestListener.php (phpunit.xml) but I have the same problem :|

@viv
viv commented Jan 3, 2012

Sorry I don't think I was clear in my previous post. The change involves adding an additional check for the PHP_CodeCoverage_Filter::getInstance() method before use in TestListener.php.

@isidromerayo

Sorry I didn't understand, it's ok.
Thanks!

@padraic
Owner

Fixed in current master branch - will update documentation to reflect the revised instructions for the listener.

@padraic padraic closed this Jan 20, 2012
@Codix

I have this error message:
Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in C:\xampp177\php\phpunit on line 39

How did you solve this problem - I don't understand this messages above. Could somebody help me step by step?

I have the newest versions of phpunit, skelgen and netbeans.

@aik099

This isn't happening on my project, where I'm using PhpUnit 3.7.x and latest Mockery release.

@Codix, maybe you need to update both and see if that helps. Maybe problem is Windows-only, I don't know, since I'm using Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment