I've just started creating Unit Tests for my code again. I have had PHPUnit working in the past but today it's not playing ball. Before I created any new tests I decided to run some old ones to see if they were still valid but I get a Fatal Error from PHPUnit itself. I run PHPUnit from the CLI in Ubuntu.
phpunit TestCaseFile
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/imap.ini on line 1 in Unknown on line 0
PHP Warning:  Xdebug MUST be loaded as a Zend extension in Unknown on line 0
Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
Warning: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
Fatal error: Class 'PHPUnit_Framework_MockObject_Matcher_InvokedRecorder' not found in /usr/share/php/PHPUnit/Framework/MockObject/Matcher/InvokedAtLeastOnce.php on line 60
Call Stack:
    0.0002     651688   1. {main}() /usr/bin/phpunit:0
    0.0031    1173168   2. require('/usr/share/php/PHPUnit/TextUI/Command.php') /usr/bin/phpunit:48
    0.0046    1485456   3. require_once('/usr/share/php/PHPUnit/TextUI/TestRunner.php') /usr/share/php/PHPUnit/TextUI/Command.php:47
    0.0047    1503344   4. require_once('/usr/share/php/PHPUnit/Framework.php') /usr/share/php/PHPUnit/TextUI/TestRunner.php:47
    0.0168    3848688   5. require('/usr/share/php/PHPUnit/Framework/TestCase.php') /usr/share/php/PHPUnit/Framework.php:68
    0.0178    4091880   6. require_once('/usr/share/php/PHPUnit/Framework/MockObject/Matcher/InvokedAtLeastOnce.php') /usr/share/php/PHPUnit/Framework/TestCase.php:49
I checked to make sure that the files exist, that the file paths etc are correct but I don't really know how to go about fixing it can anyone help?
I had this trouble on OSX. I had to remove phpunit via PEAR, add the ez component channel again, and re-install phpunit.
$ phpunit
PHP Fatal error:  Class 'PHPUnit_Framework_MockObject_Matcher_InvokedRecorder' not found in /usr/lib/php/PHPUnit/Framework/MockObject/Matcher/InvokedAtLeastOnce.php on line 60
$ sudo pear uninstall phpunit/PHPUnit
uninstall ok: channel://pear.phpunit.de/PHPUnit-3.4.11
$ sudo pear install phpunit/PHPUnit
Unknown remote channel: components.ez.no
Unknown remote channel: components.ez.no
phpunit/PHPUnit can optionally use PHP extension "dbus"
phpunit/PHP_CodeCoverage requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6)
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
phpunit/PHPUnit requires package "phpunit/PHP_CodeCoverage" (version >= 1.0.2)
phpunit/PHP_TokenStream requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6)
No valid packages found
install failed
$ sudo pear channel-discover components.ez.no
Adding Channel "components.ez.no" succeeded
Discovery of channel "components.ez.no" succeeded
$ sudo pear update-channels
....
$ sudo pear install phpunit/PHPUnit
phpunit/PHPUnit can optionally use PHP extension "dbus"
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
downloading PHPUnit-3.5.10.tgz ...
....
install ok: channel://components.ez.no/Base-1.8
install ok: channel://components.ez.no/ConsoleTools-1.6.1
install ok: channel://pear.phpunit.de/PHP_TokenStream-1.0.1
install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.0.3
install ok: channel://pear.phpunit.de/PHPUnit-3.5.10
$ phpunit
PHPUnit 3.5.10 by Sebastian Bergmann.
Sorted.
No worries people I fixed it.
It turns out that when I first installed PHPUnit I installed with APT I ran
apt-get remove phpunit
then re installed
apt-get install phpunit
Got me the latest version and all works fine. Hope this helps other people with a similar problem.
First I had this problem:
pear/XML_RPC2 requires PHP extension "curl"
So I installed php5-curl via Ubuntu Software Center.
Then there was this problem:
Unknown remote channel: components.ez.no
The dependencies could therefore not be installed. After doing this:
sudo pear channel-discover components.ez.no
everything just worked fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With