Alex Rivera | Logout

Problems with PHPUnit (Linux) - PHP Fatal Error

Asked 2011-05-19T18:14:20.160
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.

Edit
Report

2 Answers

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
answered 2012-10-12T02:31:49.780
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

answered 2012-11-27T16:57:12.987

Your Answer