wamp netbeans phpunit Selenium yii

hi

am new to YII coming from codeigniter, never used phpunit and struggled to get it to work after much searching i got it to work, and figured to share it with others, hope it helps.

************** Downloads **************

  • netbeans(6.9.1)

  • Yii( 1.1.5)

  • WampServer(2.1-x64)

note: i don’t use pear so i manually will install phpunit

I downloaded the fallowing files from http://pear.phpunit.de/

  • phpunit (3.5.7)

  • PHPUnit_Selenium (1.0.1)

  • code-coverage (1.0.3-2)

  • file-iterator (1.2.3-1)

  • text-template (1.1.0-1)

  • timer (1.0.0-10)

  • token-stream (1.0.1-3)

  • code-coverage (1.0.3-2)

************** Install **************

first lets define a constant to use in this tutorial

-PHP_Home is the directory of were the php.exe is on your pc.( example on mine is D:\wamp\bin\php\php5.3.4 ).

now install wamp first

then go into PHP_Home and create a folder called "includes" in this folder extract from the PHPUnit-3.5.7.tgz the folder PHPUnit.

now your PHP_Home\includes\PHPUnit-3.5.7\ should have in it the fallowing files.

  • phpunit.bat

  • phpunit.php

  • README.markdown

  • LICENSE

  • ChangeLog.markdown

  • PHPUnit\

now for the dependencies we need to extract in the PHP_Home\includes\PHPUnit-3.5.7\:

from the file-iterator the File folder and its content.

from the text-template the Text folder and its content.

from the timer the PHP folder and its content "timer.php".

from the code-coverage the php folder and its content

from the token-stream the PHP folder and its content "token.php and token folder"

note: don’t override any files

so now the PHP_Home\includes\PHPUnit-3.5.7\ should have in it the fallowing folders:

  • phpunit.bat

  • phpunit.php

  • README.markdown

  • LICENSE

  • ChangeLog.markdown

  • PHPUnit\

  • File\

  • PHP\

  • Text\

for the last dependencies extract form the PHPUnit_Selenium.tar the folders SeleniumTestCase and story and the file SeleniumTestCase.php to the directory PHP_Home\includes\PHPUnit-3.5.7\PHPUnit\Extensions.

now copy the phpunit.bat from PHP_Home\includes\PHPUnit-3.5.7\ and place it in PHP_Home with the php.exe.

now fix windows environment variables edit the "path" and add to it ;PHP_Home so you can run the phpunit.bat from command promote.

************** editing **************

1-the phpunit.bat that we copied to PHP_Home open it with an editor and type in it this

note:use your own install directory




@echo off

D:\wamp\bin\php\php5.3.4\php.exe  -d safe_mode=Off "D:\wamp\bin\php\php5.3.4\includes\PHPUnit-3.5.7\phpunit.php" %*



2-the phpunit.php in the directory PHP_Home\includes\PHPUnit-3.5.7\

open it with an editor and change the @php_bin@ with the directory were the php.exe is example i typed “if (strpos(‘D:\wamp\bin\php\php5.3.4\php.exe’, ‘@php_bin’) === 0)

3-the php.ini the one in the PHP_Home open it with an editor and change it use your directory and dont forget to remove the semicolon




; Windows: "\path1;\path2"

include_path = ".<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/grin.gif' class='bbc_emoticon' alt=';D' />:\wamp\bin\php\php5.3.4\includes\PHPUnit-3.5.7"

;



note:left click the wamp icon in the system tray and in the php\php.ini file do the same thing

************** Install **************

a ) install Yii by extracting the content of yii-1.1.5.r2654.zip into D:\wamp\www\ then i add to the windows environment variables "path" the location of yic.bat example "; D:\wamp\www\yii-1.1.5.r2654\framework" then i can run yic from the command promote to create a a new site i cd in the command promote to D:\wamp\www\ and then type yiic webapp demo

b ) install netbeans then fallow the directions from netbeans_and_yii written by Marcovtwout

i hope i did not forget anything. its been just one day that am using Yii and phpunit, am not sure if this is the correct way of doing it but its working for me.

good post. thanks for sharing.

very goooooood post.tanks. :rolleyes:

If I may add something to this life saving post I just used, with new versions of phpunit or something, I had to install MockObject following these steps :

  • Download PHPUnit_MockObject from pear

  • Extracting PHPUnit_MockObject-1.2.0

  • Find within it the Folder PHPUnit\Framework\MockObject

  • Copy the MockObject folder

  • Past it, in this case, in PHP_Home\includes\PHPUnit-3.5.7\PHPUnit\Framework

Hope it helps. If it does not, at least I tried to participate :)

@axmed, @kicoe: Your contribution like this is always welcome and thank you very much for your effort on adding this to Yii comunity.

Try to get more posts (ten or so, if I’m not mistaken), so you will be able to convert this posts to full wiki articles.

I found axmed’s solution personally very good, since it uses manual PHPUnit installation. It was always big problem for me as automated instalation via PEAR always seemd to be failing for me.

Thanks again for all!