0

I am using wamp 2.2 in win 7 and trying to install phpunit

1.I downoad phpunit-master.zip from https://github.com/sebastianbergmann/phpunit. 2. I unzip it. 3. I put it under D:\wamp\bin\php\php5.3.10, Then, I run below php script;

<?php
//testsuite.wordcount.php
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once "PHPUnit/Framework/TestSuite.php";
require_once "class.testwordcount.php";
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite("TestWordCount");
PHPUnit_TextUI_TestRunner::run($suite);
?>

The output is: *Warning: require_once(PHPUnit/TextUI/TestRunner.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\oop\test.php on line 4*

It seems that I did not install phpunit correctly, so what may go wrong?

2 Answers 2

4
Run the following commands (they may take a while to update):

pear channel-update pear.php.net
pear upgrade-all
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear update-channels   

 To install PHPUnit, run
    pear install --alldeps --force phpunit/PHPUnit

    To test that PHPUnit was successfully installed, run
    phpunit -v
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks. I have installed phpunit. And I can see the location of phpunit is : D:\wamp\bin\php\php5.3.10\PEAR\PHPUnit, but when i run the php file, I still got the warning message. So what is the problem and do I need to do some further configuration?
Did you test the PHPUnit existence in command Line ?, Did you restart your apache ?. If not please do that and if still exists let me know the warning you are getting.
1. I run phpunit -v command, and got the output: PHPUnit 3.7.19 by Sebastian Bergmann. Usage: phpunit [switches] UnitTest [UnitTest.php] phpunit [switches] <directory>... 2. I restarted apache, and even reboot my computer, But still got the warning message.
Did you restart your apache ??? Also, Add PHPUnit to php.ini Open up php.ini and search for “Paths and Directories”. Include your phpunit folder under include_path. looks like this: ; Windows: "\path1;\path2" include_path = ".;c:\php\includes;c:\php\phpunit"
1. yes, I have restared apache. 2. I edited two php.ini files(one is under D:\wamp\bin\php\php5.3.10, the other is under:D:\wamp\bin\apache\Apache2.2.21\bin), I made both of them to: include_path = ".;c:\php\includes;D:\wamp\bin\php\php5.3.10\PEAR", and then restarted apache again, but still see the warning message.
0

You can't just plop the files there and hope for it to work, you need to follow the installation instructions here: https://github.com/sebastianbergmann/phpunit#installation

For me, the easiest way I've found to install it is via Pear if you're happy to have it installed system wide, although this can get messy down the track with upgrades, different versions etc, or on a per project basis you can install via composer (which is my preference)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.