Yii Framework Forum: Cant get PHPUnit and selenium working correctly - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Cant get PHPUnit and selenium working correctly Rate Topic: -----

#1 User is offline   Tommo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 22-February 11

Posted 22 February 2011 - 10:19 PM

Hopefully someone will be able to help me with this because I've been pulling my hair out for hours on this one...

Background:
I am reading the Agile Web Application Development Book and I'm up to the part about testing. In this book they recommend installing Selenium and PHPUnit
I have successfully installed Selenium R C
I'm running WAMP server 2.0 on Windows Vista

Problem:
I have tried to install PHPUnit 2 ways.

1. The first way was through PEAR. PEAR managed to download it and install it okay...but when I try to run phpunit I get the following error message.

'phpunit' is not recognized as an internal or external command, operable program or batch file.


As far as I can tell this means that the phpunit executable file does not exist in my PATH environment variable. Trouble is, I cant find ANY phpunit executable file. It just doesn't seem to exist...

2. So I tried another way of installing it. I downloaded directly from GITHUB and extracted the archive to my computer. This time, I had more luck, I can get phpunit running (ie: There is an executable) but when I run it on a test case I get these error messages...

The command I ran
c:\wamp\www\yii\agile\protected\tests>phpunit functional/SiteTest.php

The error message
PHP Warning:  require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to o
pen stream: No such file or directory in C:\wamp\www\yii\framework\test\CWebTest
Case.php on line 11

Warning: require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to open s
tream: No such file or directory in C:\wamp\www\yii\framework\test\CWebTestCase.
php on line 11
PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Extensions/Se
leniumTestCase.php' (include_path='C:\wamp\bin\php\php5.3.0\PEAR;.;C:\wamp\bin\p
hp\php5.3.0\pear') in C:\wamp\www\yii\framework\test\CWebTestCase.php on line 11


Fatal error: require_once(): Failed opening required 'PHPUnit/Extensions/Seleniu
mTestCase.php' (include_path='C:\wamp\bin\php\php5.3.0\PEAR;.;C:\wamp\bin\php\ph
p5.3.0\pear') in C:\wamp\www\yii\framework\test\CWebTestCase.php on line 11


I have tried searching for that file (ie:SeleniumTestCase.php) on the net but can barely find any information on it. I can't find it on my HD so where do I get a copy of it?

Does anyone know how to fix this problem? I'm completely stumped and I would be so grateful if someone could help me out.

Thanks heaps
Tom
0

#2 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 23 February 2011 - 02:26 AM

SeleniumTestCase.php should be in the PHPUnit folder - "PHPUnit/Extensions/SeleniumTestCase.php".
I think you need to add the folder with PHPUnit to the PATH.

I managed to install and run php unit and Selenium on Windows, so it is definitely possible.
But now developing on Ubuntu where I just run
  pear channel-discover pear.phpunit.de
  pear install phpunit/PHPUnit

0

#3 User is offline   Tommo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 22-February 11

Posted 23 February 2011 - 03:07 AM

Thanks for your reply Seb,

Quote

SeleniumTestCase.php should be in the PHPUnit folder


That's what I would expect...but it's not. I've even uninstalled and reinstalled several times and it's just not in there...

When you installed in Windows did you do so via PEAR or direct download?
0

#4 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 23 February 2011 - 07:22 AM

Unfortunately I don't remember how exactly I installed it.
But is seems that SeleniumTestCase goes from the separate package "PHPUnit_Selenium", see description here.
0

#5 User is offline   Tommo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 22-February 11

Posted 24 February 2011 - 03:16 PM

Thanks for your help Seb,

I have got it working now...

For anyone else who is having the same problem...

Using the pear installer doesn't seem to work very well.

So I downloaded PHPUnit_Selenium and PHPUnit packages from pear.phpunit.de/

These are tgz files so you just unzip them to your include directory as specified in php.ini Make sure the phpunit_selenium file/folder structure is merged with the phpunit file/folder structure.

Then you should be good to go!
0

#6 User is offline   Nev 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 14-March 11

Posted 14 March 2011 - 03:14 AM

I've just been getting exactly the same error. I had removed phpunit using pear, then installed it using apt-get because I wanted an older version, then decided that version was too old, so I removed the version from the repos and installed an older version using pear. Because the selenium stuff is a dependency, but lives inside phpunit, and pear lets you uninstall phpunit without uninstalling the selenium stuff first the pear uninstall of phpunit breaks the pear installed PHPUnit_Selenium, but it remains installed. So that's the root of the problem.

The fix is to uninstall them both, then reinstall phpunit which will then reinstall selenium.

For example... (I downgraded to 3.5.6 because I want --verbose to work like it used to.)

#sudo pear uninstall phpunit/PHPUnit_Selenium
uninstall ok: channel://pear.phpunit.de/PHPUnit_Selenium-1.0.2
#sudo pear install phpunit/PHPUnit-3.5.6
phpunit/PHPUnit can optionally use PHP extension "dbus"
downloading PHPUnit-3.5.6.tgz ...
Starting to download PHPUnit-3.5.6.tgz (112,204 bytes)
.........................done: 112,204 bytes
downloading PHPUnit_Selenium-1.0.2.tgz ...
Starting to download PHPUnit_Selenium-1.0.2.tgz (16,412 bytes)
...done: 16,412 bytes
install ok: channel://pear.phpunit.de/PHPUnit_Selenium-1.0.2
install ok: channel://pear.phpunit.de/PHPUnit-3.5.6
#


If this isn't exactly the same problem as you had it is at least the same symptom...

PHP Warning:  require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to open stream: No such file or directory in...


I'm doing it on Debian 6.0.
0

#7 User is offline   Matt2012 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 18-September 09

Posted 05 July 2011 - 03:21 PM

Also had this issue windows 7 64bit after updating phpunit 3.5.14

I just downloaded the PHPUnit_Selenium files manually from Tommo's link added it into the PHPUnit directory under pear and that did the trick.
0

#8 User is offline   Sebastian 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 15-June 11

Posted 01 September 2011 - 09:29 AM

In my case, PHPUnit was already installed. Trying
pear install phpunit/phpunit_selenium

returned
phpunit/phpunit_selenium is already installed and is the same as the released version 1.0.3
install failed


So I did
pear upgrade -f phpunit/phpunit_selenium


And it worked. PHPUnit runs without the error now.
0

#9 User is offline   HomanXH 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 05-June 11

Posted 07 September 2011 - 10:38 AM

In my windows experience:
First: it's a batch file error. Goto PHP dir, find phpunit.bat and edit path in the file.

Second, the phpunit.bat must be in the executable path. Check path in command line in CMD windows.

Third, don't fill anything in open_basedir in php.ini. Or you get open stream error in the php log.

Fourth, download and run selenium server in seperate windows:
example: java -jar c:\php\bin\selenium-server-standalone-2.5.0.jar
and don't close it unitl your test is done.

Finally, read the Agile book. The chapter 3 is working fine. Don't miss any paragraphs. Don't lost in space.
0

#10 User is offline   blacksheep 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 180
  • Joined: 31-December 11

Posted 11 January 2012 - 04:26 AM

View PostSebastian, on 01 September 2011 - 09:29 AM, said:

In my case, PHPUnit was already installed. Trying
pear install phpunit/phpunit_selenium

returned
phpunit/phpunit_selenium is already installed and is the same as the released version 1.0.3
install failed


So I did
pear upgrade -f phpunit/phpunit_selenium


And it worked. PHPUnit runs without the error now.


Hi, i have the error
PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Extensions/SeleniumTestCase.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/yiiTest/framework/test/CWebTestCase.php on line 11



if i do
pear install phpunit/phpunit_selenium


i have this error
PHPUnit 3.6.7 by Sebastian Bergmann.

Cannot open file "functional/PostTest.php".


i have ubuntu server 11.10

Thanks!
So di non Sapere
0

#11 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 11 January 2012 - 11:44 AM

Google for it. phpunit seems to be broken on Ubuntu in the latest releases. Try this:

http://askubuntu.com...pgrade-to-11-04
0

#12 User is offline   frm683 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 04-April 12

Posted 04 April 2012 - 05:13 AM

Well Guys I'm also in same book and same chapter first I had following error :

E:\xampp\htdocs\YiiRoot\protected\tests>phpunit functional/SiteTest.php
PHP Warning: require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to o
pen stream: No such file or directory in E:\xampp\htdocs\yii\framework\test\CWeb
TestCase.php on line 11

Warning: require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to open s
tream: No such file or directory in E:\xampp\htdocs\yii\framework\test\CWebTestC
ase.php on line 11
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Extensions/Se
leniumTestCase.php' (include_path='.;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\
framework\test\CWebTestCase.php on line 11

Fatal error: require_once(): Failed opening required 'PHPUnit/Extensions/Seleniu
mTestCase.php' (include_path='.;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\frame
work\test\CWebTestCase.php on line 11


and then following this forum user Tommo given some instructions to follow when did as it is I extracted the files from PHPUnit packages from pear.phpunit.de version 1.2.6 (stable) and copied to E:\xampp\php\PEAR\PHPUnit\Extensions to folder now when I execute the following line
E:\xampp\htdocs\YiiRoot\protected\tests>phpunit functional/SiteTest.php

I get this :


Configuration read from E:\xampp\htdocs\YiiRoot\protected\tests\phpunit.xml

PHP Warning: include(SiteTest: Firefox.php): failed to open stream: No such fil
e or directory in E:\xampp\htdocs\yii\framework\YiiBase.php on line 338

Warning: include(SiteTest: Firefox.php): failed to open stream: No such file or
directory in E:\xampp\htdocs\yii\framework\YiiBase.php on line 338
PHP Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (i
nclude_path='.;E:\xampp\htdocs\YiiRoot\protected\components;E:\xampp\htdocs\YiiR
oot\protected\models;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\framework\YiiBas
e.php on line 338

Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (includ
e_path='.;E:\xampp\htdocs\YiiRoot\protected\components;E:\xampp\htdocs\YiiRoot\p
rotected\models;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\framework\YiiBase.php
on line 338
SSSPHP Warning: include(SiteTest: Firefox.php): failed to open stream: No such
file or directory in E:\xampp\htdocs\yii\framework\YiiBase.php on line 338

Warning: include(SiteTest: Firefox.php): failed to open stream: No such file or
directory in E:\xampp\htdocs\yii\framework\YiiBase.php on line 338
PHP Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (i
nclude_path='.;E:\xampp\htdocs\YiiRoot\protected\components;E:\xampp\htdocs\YiiR
oot\protected\models;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\framework\YiiBas
e.php on line 338

Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (includ
e_path='.;E:\xampp\htdocs\YiiRoot\protected\components;E:\xampp\htdocs\YiiRoot\p
rotected\models;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\framework\YiiBase.php
on line 338


Time: 5 seconds, Memory: 5.00Mb

OK, but incomplete or skipped tests!
Tests: 3, Assertions: 0, Skipped: 3.


please advice how to fix this problem.
0

#13 User is offline   Havunen 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 06-April 12

Posted 06 April 2012 - 08:42 AM

View Postfrm683, on 04 April 2012 - 05:13 AM, said:

Well Guys I'm also in same book and same chapter first I had following error :

E:\xampp\htdocs\YiiRoot\protected\tests>phpunit functional/SiteTest.php
PHP Warning: require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to o
pen stream: No such file or directory in E:\xampp\htdocs\yii\framework\test\CWeb
TestCase.php on line 11

Warning: require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to open s
tream: No such file or directory in E:\xampp\htdocs\yii\framework\test\CWebTestC
ase.php on line 11
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Extensions/Se
leniumTestCase.php' (include_path='.;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\
framework\test\CWebTestCase.php on line 11

Fatal error: require_once(): Failed opening required 'PHPUnit/Extensions/Seleniu
mTestCase.php' (include_path='.;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\frame
work\test\CWebTestCase.php on line 11


and then following this forum user Tommo given some instructions to follow when did as it is I extracted the files from PHPUnit packages from pear.phpunit.de version 1.2.6 (stable) and copied to E:\xampp\php\PEAR\PHPUnit\Extensions to folder now when I execute the following line
E:\xampp\htdocs\YiiRoot\protected\tests>phpunit functional/SiteTest.php

I get this :


Configuration read from E:\xampp\htdocs\YiiRoot\protected\tests\phpunit.xml

PHP Warning: include(SiteTest: Firefox.php): failed to open stream: No such fil
e or directory in E:\xampp\htdocs\yii\framework\YiiBase.php on line 338

Warning: include(SiteTest: Firefox.php): failed to open stream: No such file or
directory in E:\xampp\htdocs\yii\framework\YiiBase.php on line 338
PHP Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (i
nclude_path='.;E:\xampp\htdocs\YiiRoot\protected\components;E:\xampp\htdocs\YiiR
oot\protected\models;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\framework\YiiBas
e.php on line 338

Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (includ
e_path='.;E:\xampp\htdocs\YiiRoot\protected\components;E:\xampp\htdocs\YiiRoot\p
rotected\models;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\framework\YiiBase.php
on line 338
SSSPHP Warning: include(SiteTest: Firefox.php): failed to open stream: No such
file or directory in E:\xampp\htdocs\yii\framework\YiiBase.php on line 338

Warning: include(SiteTest: Firefox.php): failed to open stream: No such file or
directory in E:\xampp\htdocs\yii\framework\YiiBase.php on line 338
PHP Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (i
nclude_path='.;E:\xampp\htdocs\YiiRoot\protected\components;E:\xampp\htdocs\YiiR
oot\protected\models;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\framework\YiiBas
e.php on line 338

Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (includ
e_path='.;E:\xampp\htdocs\YiiRoot\protected\components;E:\xampp\htdocs\YiiRoot\p
rotected\models;E:\xampp\php\PEAR') in E:\xampp\htdocs\yii\framework\YiiBase.php
on line 338


Time: 5 seconds, Memory: 5.00Mb

OK, but incomplete or skipped tests!
Tests: 3, Assertions: 0, Skipped: 3.


please advice how to fix this problem.



I'm having the same probelm, did you ever find solution for this ?
0

#14 User is offline   Havunen 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 06-April 12

Posted 07 April 2012 - 07:54 AM

View PostHavunen, on 06 April 2012 - 08:42 AM, said:

I'm having the same probelm, did you ever find solution for this ?


I solved this problem simply by uninstalling all java programs through control panel and reinstalled java SDK, then redownloaded selenium RC server moved it to Java SDK installation folder / bin and started server from cmd: java -jar selenium.jar

code was throwing error because selenium wasn't working correctly (couldn't start browser)
0

#15 User is offline   za_al 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 06-March 12

Posted 08 May 2012 - 02:41 AM

install selenium after install phpunit with tuhis step:

C:\xampp\php>PEAR install phpunit/DbUnit

Open "php.in" (C:\xampp\php) and uncomment "extension=php_curl.dll"

C:\xampp\php>pear install phpunit/PHPUnit_Selenium

see following link for more info:

Latest PHPUnit-3.6.10 and Selenium server issue
0

#16 User is offline   Vinoth 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 10-May 12

Posted 12 May 2012 - 09:05 AM

View PostSebastian, on 01 September 2011 - 09:29 AM, said:

In my case, PHPUnit was already installed. Trying
pear install phpunit/phpunit_selenium

returned
phpunit/phpunit_selenium is already installed and is the same as the released version 1.0.3
install failed


So I did
pear upgrade -f phpunit/phpunit_selenium


And it worked. PHPUnit runs without the error now.

Thanks a lot Sebastian, your
pear upgrade -f phpunit/phpunit_selenium
helped me lot to solve this problem.
1

#17 User is offline   voodoo-max 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 21-May 12

Posted 01 June 2012 - 04:15 AM

View PostHavunen, on 07 April 2012 - 07:54 AM, said:

I solved this problem simply by uninstalling all java programs through control panel and reinstalled java SDK, then redownloaded selenium RC server moved it to Java SDK installation folder / bin and started server from cmd: java -jar selenium.jar

code was throwing error because selenium wasn't working correctly (couldn't start browser)


It didn't help me. I tried to reinstall all including Java SDK, PEAR, PHPUnit, Selenium... Several times. Tried all the ways I could find in Google. My configuration: Win7 x64, Apache 2.4.2, PHP 5.3.13, PEAR 1.9.4, PHPUnit 3.6.11 , PHPUnit_Selenium 1.2.7, selenium-server-standalone-2.22.0.jar, Yii 1.1.10.

It's interesting that PHPUnit is working, tests are passing. But every time I see the next warnings in my console:
"Warning: include(): Failed opening 'SigupTest: Firefox.php' for inclusion (include_path=.;C:\{path_to_yii_application}\protected\components;C:\{path_to_yii_application}\protected\models;C:\usr\local\php\PEAR\pear;C:\usr\local\php\includes') in C:\{path_to_yii_application}\framework\YiiBase.php on line 418"

Anybody knows the reason?
0

#18 User is offline   Haensel 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 444
  • Joined: 14-January 11
  • Location:Vienna (Austria)

Posted 01 June 2012 - 05:16 AM

I am sure you already thought about that one but shouldn't "SigupTest: Firefox.php" be "SignupTest: Firefox.php" Maybe this is a simple typo thing
0

#19 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 29 June 2012 - 04:32 PM

I finally managed to setup phpUnit and Selenium on both Win7 and Ubuntu 12.04 with Netbeans.

Many of the problems mentioned above seem to be with how phpUnit was installed.
I found it only works properly if you use Pear.

However you installed it, if it's still not working, uninstall and reinstall like this:


sudo pear channel-discover pear.phpunit.de

sudo pear uninstall phpunit/PHPUnit

sudo pear uninstall phpunit/PHPUnit_Selenium

sudo pear install phpunit/PHPUnit

// make sure curl is installed before the next command.

sudo pear install phpunit/PHPUnit_Selenium


Ignore the 'sudo' part if your Linux distro doesn't need it or if using Windows.

If you're using Netbeans, you will need to make sure you have the Selenium plugins installed. You don't need the 'Maven' or 'Ant' plugins though.

I still have to figure out what the problem is with this:

"Warning: include(): Failed opening 'MyTest: Firefox.php' for inclusion..."
"Warning: include(): Failed opening 'MyTest: Chrome.php' for inclusion..."


The tests work regardless so no biggie.
0

#20 User is offline   Bynton 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 09-July 12

Posted 17 July 2012 - 10:43 PM

Well after reviewing your problem i get one solution. I think you need to add the folder with PHPUnit to the PATH.
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users