Sorry if this is trivial but I did not find any advice how to fix this. I am on Ubuntu and need PHPUnit for my Yii project. I have installed PHPUnit twice, by downloading and moving phpunit.phar to '/usr/local/bin' and by running:

composer global require "phpunit/phpunit=3.7.*"

Now I am trying to execute my Yii PHPUnit test:

phpunit unit/DbTest.php

And what I get is:

PHP Warning:  require_once(PHPUnit/Extensions/SeleniumTestCase.php): 
failed to open stream: No such file or directory in 
/opt/lampp/htdocs/yii-project/framework/test/CWebTestCase.php on line 12

PHP Fatal error:  require_once(): Failed opening required 
(include_path='.:/usr/share/php:/usr/share/pear') in 
/opt/lampp/htdocs/yii-project/framework/test/CWebTestCase.php on line 12

So it seems that it can't find PHPUnit extension SeleniumTestCase.php. Then PHPUnit installation manual states that Selenium 'is included in the PHAR distribution of PHPUnit.'. Can you suggest what do I do to make my Yii test work?

Was it helpful?

Solution 2

What I did to fix this:

1) I have downloaded selenium extensions from: and placed the entire PHPUnit directory under


At that point PHPUnit stopped complaining about missing SeleniumTestCase.php.

2) Then I got an error about missing file in


To fix this I commented out these lines in CTestCase.php:

//require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11

Now I am able to run my tests.


You need to install optional additional packages of phpunit for Yii testing to run

The packages you would need are


You can install them using composer by adding the following to require-dev

"phpunit/php-invoker": "*",
"phpunit/dbunit": ">=1.2",
"phpunit/phpunit-selenium": ">=1.2",
"phpunit/phpunit-story": "*"

use the following commands to install the respective dependencies

composer global require 'phpunit/phpunit-selenium=*'
composer global require 'phpunit/phpunit-story=*'
composer global require 'phpunit/dbunit=*'
composer global require 'phpunit/php-invoker=*'

Here is what worked for me

sudo pear config-set auto_discover 1
sudo pear channel-discover
sudo pear install --alldeps
sudo pear install --alldeps
sudo pear install --alldeps
sudo pear install --alldeps

In time of replying this, it is necessary to little bit amend Manquer's response. It is necessary to edit CWebTestCase and include Selenium2TestCase.php instead of SeleniumTestCase.php and extending PHPUnit_Extensions_Selenium2TestCase instead of PHPUnit_Extensions_SeleniumTestCase. Php-invoker is not possible to install on Windows and it is not necessary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top