13

I successfully installed PHPUnit on my desktop PC and decided to have it on my laptop PC, but... then I try to create PHPUnit test Netbeans throws an error "Selected PHPUnit (version ?.?.?) is to old, upgrade it if possible (the minimum version is 3.3.0).".

Of course my PHPUnit version is newer - 3.5.5-2. Where is the problem?

I am using

  • Ubuntu 11.04
  • Netbeans 6.9
  • PEAR Version: 1.9.1
  • PHP Version: 5.3.5-1ubuntu7.2
  • Zend Engine Version: 2.3.0

As I understand the problem is with PHPUnit. When I try to call "phpunit" command in terminal I receive PHP Fatal error:

root@ubuntu:~# phpunit –version
PHP Warning:  require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP Fatal error:  require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 38
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
root@ubuntu:~# find / -name CodeCov*
root@ubuntu:~#

As you can see there is no such file or folder in my PC. What to do?

I tried to reinstall it many times (with apt-get, pear, Synaptic PM...), but always get the same result.

3
  • 5
    Don't sit in a root shell. That is a very bad habit. Commented May 19, 2011 at 18:16
  • Did you use PEAR to install PHPUnit? Commented May 19, 2011 at 18:42
  • 1
    Have you installed all of its dependencies, specifically PHP_CodeCoverage? Commented May 19, 2011 at 19:51

5 Answers 5

24

Problem solved.

Follow @David Harkness comment I tried to install PHP_CodeCoverage and then I realized that my PEAR Installer is too old. I Upgraded it to 1.9.2 and then reinstalled PHPUnit.

$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar
$ pear install phpunit/PHPUnit

What's quite strange because all software was freshly installed week ago.

Answer. How I installed PHPUnit finally.

sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear install phpunit/PHP_CodeCoverage
sudo pear install phpunit/PHPUnit

If You still have problems try to update PEAR:

sudo wget http://pear.php.net/go-pear.phar
sudo php go-pear.phar
Sign up to request clarification or add additional context in comments.

1 Comment

This is a known dependency bug that it is still not fixed: bugs.launchpad.net/ubuntu/+source/phpunit/+bug/701544
8
  1. configure channel autodiscovery

    sudo pear config-set auto_discover 1

  2. simply upgrade / install phpunit with --alldeps flag enabled

    sudo pear upgrade --alldeps channel://pear.phpunit.de/PHPUnit

and it automatically does the necessary magics. :)

Update: http://pear.phpunit.de/ has gone away (Returns 410)

1 Comment

invalid package name/package file "channel://pear.phpunit.de/PHPUnit"
3

The other solutions here did not work for me. I finally found a solution that worked for me here: http://markojakic.net/configure-phpunit-and-pear-in-ubuntu-12-04

Essentially pear by default for me was installing binaries to my home directory. To fix it I ran the following commands

sudo pear config-set bin_dir /usr/bin
sudo pear config-set doc_dir /usr/share/php/doc
sudo pear config-set php_dir /usr/share/php
sudo pear config-set cfg_dir /usr/share/php/cfg (make (sudo mkdir cfg) directory here)
sudo pear config-set data_dir /usr/share/php/data
sudo pear config-set test_dir /usr/share/php/test

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

Comments

3

PHAR FTW!

$ wget http://pear.phpunit.de/get/phpunit.phar
$ chmod +x phpunit.phar

Ref: https://github.com/sebastianbergmann/phpunit/blob/master/README.md

Comments

1

To get the latest version of pear and phpunit.

pear upgrade
pear upgrade pear
pear upgrade phpunit/PHPUnit

1 Comment

this worked, but I had to run pear channel-discover pear.phpunit.de before the last line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.