Yii phpunit error SeleniumTestCase.php fail to open stream

675 views Asked by At

I have installed phpunit based on the instructions in this website (the 'Windows' sub-menu in the right side menu bar) for Yii:

https://phpunit.de/manual/current/en/installation.html

When I run my database connection test:

phpunit unit/DbTest.php

I get the below error:

require_once(PHPUnit/Extensions/SeleniumTestCase.php) failed to open stream. No such file or directory in C:/wamp/www/yii/framework/test/CWebTestCase.php on line 12

Then I googled the error and tried the following instructions (which don't work)
1. Install phpunit using pear (no longer supported)
2. Download phpunit/extension folder from github and put it in my C:/wamp/www/yii/framework/test/ . Then the error become:

Cannot redeclare class PHPUnit_Extensions_SeleniumTestCase in C:\wamp\www\yii\framework\test\PHPUnit\Extensions\SeleniumTestCase.php on line 1217 

How should I fix this? I am using Windows 8 with wamp server.

2

There are 2 answers

1
Bob On

try

pear upgrade -f phpunit/phpunit_selenium

hope this helps you.

0
SamMaj On

I had the same problem and followed the exact same steps as you included; trying pear and putting the PHPUnit folder inside tests.
To fix your final error you just need to comment out the following line (in my code it was on line 12) in:
yii-framework/framework/test/CWebTestCase.php

//require_once('PHPUnit/Extensions/SeleniumTestCase.php');