Page 1 of 1

PHPUnit

Posted: Fri Oct 13, 2006 11:05 am
by kpraman
Hello,

I downloaded PHPUnit PHPUnit-3.0.0beta1. Extracted to a folder and tried to test a sample test. But i am getting errors like....Warning: require_once(PHPUnit/Framework.php). i have even checked the path. Every thing seems to be correct. Can anyone guide me to get it installed?

Regards,

kpraman

Posted: Fri Oct 13, 2006 12:32 pm
by dbevfat
I believe you have three options:

1) installing with PEAR (see http://www.phpunit.de/pocket_guide/3.0/ ... ation.html)

2) downloading it yourself. This way is just fine, but you must add the parent path of PHPUnit directory to include_path of php (either by editing php.ini or at runtime with set_include_path(), see PHP manual for details).

For example, if you install PHPUnit in /var/php/libs/PHPUnit, the path /var/php/libs must be added to include_path.

3) Another option is to checkout the project from the svn repository, but again you must add that path.

Posted: Mon Oct 16, 2006 12:25 am
by kpraman
Thanks for the reply. Its working now.

Posted: Mon Oct 16, 2006 7:57 am
by kpraman
if i give,

require_once '../library/PHPUnit.php';

it is working. but, if i give require_once '../library/PHPUnit2.php'; same error occurs. PHPUnit2.php is in same library folder

Posted: Tue Oct 17, 2006 2:59 am
by Maugrim_The_Reaper
Get the file path to PHPUnit on your system. Then add it to your test file's include path.

Code: Select all

set_include_path(
    get_include_path() . PATH_SEPARATOR . "my/path/from/test/to/PHPUnit"
);
If you want a single PHPUnit directory for all your PHP projects, set up PEAR and update it to the alpha. PEAR should already come prepackaged with PHPUnit 2.

AFAIK you start by including the relevant framework component. i.e. once it's installed to PEAR (and PEAR is on the include path) or once you set up the include path as above...

Code: Select all

require_once 'PHPUnit/Framework/TestCase.php';
Then write your test case for the test... See the PHPUnit docs - it's the external homepage link from the PEAR page for PHPUnit2

PHPUnit2

Posted: Tue Nov 07, 2006 3:54 am
by kpraman
I am currently using PHPUnit-1.3.2.

PHPUnit is located in,

server/project/classes/library/PHPUnit


in the testcase files, i am using the following code...

Code: Select all

<?php 
set_include_path("library/"); 

require_once 'members.php'; 
require_once 'PHPUnit/Framework/TestCase.php'; 
require_once 'PHPUnit.php'; 

class MembersTest extends PHPUnit_TestCase { 
....... 
...... 

?>
This is working.

if i want to use PHPUnit-2.3.6 What are the changes i have to make?. I am getting errors.

Posted: Tue Nov 07, 2006 5:42 am
by Maugrim_The_Reaper
Check the internal 2.3.x references. If they are including from a PHPUnit2 directory then PHPUnit2 is what you need to use in your test files. I tried setting up 2.x.x via PEAR a while back and it was throwing include errors. I predominantly use SimpleTest (I also help do general maintenance for it) so I'm not entirely up to speed on the current setup.

Posted: Fri Jan 05, 2007 4:19 am
by R@mzes
Hi, I think that article will be usefull