[Install PHPUnit] Installing PEAR and PHPUnit on WAMP and Windows 7 (no longer maintained from PHPUnit 3.7)

First of all, thanks to @Sebastian Bergmann for reminding and sorry for my careless about this reblog because End of Life for PEAR Installation Method to PHPUnit from github and The package PHPUnit is not maintained anymore and has been superseded. Package has moved to channel pear.phpunit.de, package PHPUnit from pear.php.net.

So this blog should be a reblog of installing PHPUnit(<3.7) in Windows7 from http://thecancerus.com/ and I found it was still useful for understanding the theory of configuration of php(in wamp) and the environment variables.

The newest manual installation of PHPUnit in windows can be found its documentation.

Continue reading


[PHPUnit] Testing output

Test contains not only unit test, integration test, but also the output of screen, including files etc.

For example, with the function exceptOutputString, we can test the string output by echo or print.

class OutputTest extends PHPUnit_Framework_TestCase
    public function testExpectFooActualFoo()
        $this->outputString();    // Call my local function
        $this->expectOutputString('Hello world!');    // Comparaison

    // local function 
    private function outputString()
        echo "Hello world!";

Ref. Methods for output testing

[PHPUnit] Failed opening required autoload.php error

After a re-installation of the operating system Ubuntu 12.04, I got a problem by installing/using PHPUnit, this maybe not the same as your case, but I posted it just for sharing, I hope that could help.

Before all, I just want to remind that Using the PEAR Installer to install PHPUnit is no longer supported, more info in pear.phpunit.de and github.
Continue reading

[PHPUNIT][ECLIPSE] PHPUnit/Autoload.php no such file in eclipse

IDE : eclipse

Error :

Warning: require(PHPUnit/Autoload.php): failed to open stream: 
No such file or directory

Solution :
Locate first your PHPUnit, that is to say, verify whether 
PHPUnit folder is already in /usr/share/php, if yes, take a look at 
the diagram below, in your eclipse, go to Window, then Preference, 
then PHP Include Path, then Libraries, click Add External Source Folder. 
Add /usr/share/php in your Libraries and PHPUnit will work well.
 Continue reading 

Installation and configuration of PHPUnit in Windows

Installation and configuration of PHPUnit in Windows

Version control

Language:PHP 5.3.0(>5.2.7)
Web Server:WampServer Version 2.0
System:Windows 7
Folder path:c:\wamp\bin\php
PHP version should greater than 5.2.7. To install a new version of PHP, click the icon of Wamp, and then php->Version -> Get more.

Attention: if you install a new version PHP, after the installation, it is better to check the environment variable PHP_PEAR_PHP_BIN is point to the new folder of PHP. And the php.ini which will used by command line is the one you could find in the new folder of PHP.

Continue reading