Call undefined method PHP_CodeCoverage_Filter :: getInstance ()

I have a new version of PHPUnit installed on my system (Ubuntu 11), but whenever I type phpunit in the console, I get the following error:

PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/bin/phpunit on line 39

I have PHPUnit code coverage as far as I know:

>sudo pear install phpunit/PHP_CodeCoverage

phpunit/PHP_CodeCoverage is already installed and is the same as the released version 1.1.1

install failed

Why am I getting this error and how to fix it?

+48
ubuntu phpunit pear
Feb 08 2018-12-12T00:
source share
7 answers

The executable script that loads PHPUnit should not be updated when switching to 3.6.x. Reinstall it.

 sudo pear uninstall phpunit/PHPUnit sudo pear install phpunit/PHPUnit 

If this does not work, make sure PEAR is updated itself .

+34
Feb 08 2018-12-12T00:
source share

Ubuntu 11.10 had a problem that has not been fixed. This is the only thing that will help phpunit work with the pear. (Outside of using a pear, you can find a way to do it without a pear. There is an article on the Internet about this, but I would not want it to be connected manually.) This is the only thing that worked for me:

 sudo apt-get remove phpunit sudo pear channel-discover pear.phpunit.de sudo pear channel-discover pear.symfony-project.com sudo pear channel-discover components.ez.no sudo pear update-channels sudo pear upgrade-all sudo pear install --alldeps phpunit/PHPUnit sudo pear install --force --alldeps phpunit/PHPUnit 
+118
Feb 23 '12 at 5:21
source share

For some, the Anthony solution will not work completely due to Unknown remote channel: pear.symfony.com or phpunit/PHPUnit requires package "channel://pear.symfony.com/Yaml" .

SO is an advanced solution that solves this:

 sudo apt-get remove phpunit sudo pear channel-discover pear.phpunit.de sudo pear channel-discover pear.symfony-project.com sudo pear channel-discover components.ez.no sudo pear channel-discover pear.symfony.com sudo pear update-channels sudo pear upgrade-all sudo pear install pear.symfony.com/Yaml sudo pear install --alldeps phpunit/PHPUnit sudo pear install --force --alldeps phpunit/PHPUnit 
+23
Dec 20 2018-12-12T00:
source share

The getInstance() method seems to have been excluded from the class. https://github.com/sebastianbergmann/php-code-coverage/blob/master/PHP/CodeCoverage/Filter.php#L78

Use the constructor instead if you run into this error. However, this does not apply to discovery, as the team came from PHPUnit itself.

+1
Jul 01 '12 at 15:56
source share

he works for me. at the beginning I didn’t use -force for the last command, I got a fatal error that “calls the undefined method PHP_CodeCoverage_Filter :: getInstance”. Then I used --force, which solved this problem.

+1
Aug 08 '13 at 6:53 on
source share

While I had the same problem, and I was able to solve it by setting the correct environment variables.

You can solve this problem http://rkrants.blogspot.in/2013/01/installing-phpunitpear-in-ubuntu-1210.html

In short, I had to reinstall PHPUnit using a pear, after setting the variables correctly.

I used the installation of Ubuntu 12.10 and now it works fine.

0
Jan 04 '13 at 18:15
source share

I ran into the same problem, managed to solve it using the composer

Try the following steps -

Remove phpunit first

 sudo apt-get remove phpunit 

Install composer - http://getcomposer.org/doc/01-basic-usage.md#installation

 $ curl -sS https://getcomposer.org/installer | php 

Install phpunit - http://phpunit.de/manual/3.7/en/installation.html

For a system-wide installation through Composer, you can run:

 $ composer global require 'phpunit/phpunit=3.7.*' 

You also need to make sure that you have ~ / .composer / vendor / bin / in your path.

0
Jan 01 '14 at 5:31 on
source share



All Articles