PHPUnit2/PHPUnit3 installation

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

PHPUnit2/PHPUnit3 installation

Post by kpraman »

Hello,

Is it possible to use phpunit 2 or phpunit 3 by using the include statement without installing? (As we do with phpunit 1.3)?

Thanx
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have you tried it?
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

i tried i am getting error.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

.....and the error is.....
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

i renamed phpunit to phpunit2.php, i did not change #!@php_bin@. what path should i have to give there?

in the testcase,

Code: Select all

<?php


		set_include_path("PHPUNIT2/");
		
		
		require_once 'membertypes.php';
		require_once 'PHPUnit2.php';



...
?>
#!@php_bin@
Warning: require(PHPUnit2/TextUI/TestRunner.php) [function.require]: failed to open stream: No such file or directory in D:\Projects\proj1\classes\PHPUNIT2\PHPUnit2.php on line 40

Fatal error: require() [function.require]: Failed opening required 'PHPUnit2/TextUI/TestRunner.php' (include_path='PHPUNIT2/') in D:\Projects\proj1\classes\PHPUNIT2\PHPUnit2.php on line 40


Thanx
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Based on your require usage, you should have a file at location (relative):
PHPUNIT2/PHPUnit2/TextUI/TestRunner.php

And yes, the PHPUnit2 directory really should be inside the all-capitals PHPUNIT2 directory. The include_path should point to whichever directory contains the PHPUnit2 package under the PEAR convention. Also, when setting an include path, for compatibility with any other PEAR or included paths, you should add your path to the contents of get_include_path().
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

Could you pls elobrate your reply?

1. what should i type in the place of #!@php_bin@.

2. i was using PHPUnit 1 inside a PHPUNIT folder, in the code i was using set_include_path("PHPUNIT/"); , now i replaced PHPUnit2 inside the folder
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Just reiterating that:

PHPUnit2/TextUI/TestRunner.php is a relative path *from* the parent include_path entry. If you have set the include_path to PHPUnit2 and your capitalised PHPUNIT2 is not a parent directory (i.e. above the non-capitalised PHPUnit2) than you have the include_path setup wrong - hence the fatal error if using from a webserver.

If using the PHP command line, you should add the include_path directly to the php.ini file. Also be warned - on Windows the PHP command line will use any php.ini file in the Windows or System32 folders in favour of any other alternative. I've seen some people installing standalone PHP versions, then installing other alternatives like XAMPP, and forget to delete the old php.ini instances. Makes for some puzzling moments when using PHP CLI - e.g. managing your PEAR packages.

php_bin should be set as an environment variable in your system. Its value is the full path to the PHP bin directory - see your PHP install for details.
Post Reply