Install PHPUnit on WampServer

I'm using WampServer 2.1 (with PHP 5.3.4) on Windows 7 64-bit.

This guide was made with the help of Itay Adler.

Step 1 - Installing the PEAR package manager

  • Add the php directory (in my case "d:\wamp\bin\php\php5.3.4") to your PATH (via Advanced System Settings, Environment Variables)
  • Download http://pear.php.net/go-pear.phar to somewhere (let's say "C:\Temp\pear")
  • Open a new command prompt as an administrator:
      c:
      cd c:\temp\pear
      php go-pear.phar
        

Step 2 - Installing PHPUnit

Open a new command prompt as an administrator:
  pear config-set auto_discover 1
  pear install pear.phpunit.de/PHPUnit

Step 3 - Testing PHPUnit

  • Create a file called "MyTest.php" with the following code:
      <?php
    
      class MyTest extends PHPUnit_Framework_TestCase
      {
        public function testOneEqualsOne()
        {
          $this->assertEquals(1, 1);
        }
      }
    
      ?>
        
  • Open a new command prompt and run: "phpunit MyTest.php"
  • You should see the following output:
      PHPUnit 3.5.15 by Sebastian Bergmann.
    
      .
    
      Time: 0 seconds, Memory: 5.25Mb
    
      OK (1 test, 1 assertion)
        

Comments

Anonymous said…
Thanks so much
Aigor
Anonymous said…
Thanks for the tip
Anonymous said…
Thank you so much. It works like a charm
Anonymous said…
Thanks David. it works!!!
Santhosh S said…
Thanks David.... Nice tutorial.
AllanTK said…
Thanks for the tip.

Note: If install fail after "pear install pear.phpunit.de/PHPUnit", because of "pear dupplicate package channel file iterator conflict"

pear clear-cache
pear install phpunit/File_Iterator
pear install phpunit/Text_Template
pear install --force --alldeps pear.phpunit.de/PHPUnit

Source: http://stackoverflow.com/questions/13023808/unable-to-install-latest-phpunit-in-ubuntu-10-04
Thab said…
I followed your instructions exactly and it appears to have installed correctly. Unfortunately I still get >'phpunit' is not recognized as an internal or external command,
operable program or batch file.

I have the two variable values declared C:\wamp\bin\php\php5.3.10 and C:\wamp\www\yii\framework. Please help
Thab said…
I followed your instructions exactly and it appears to have installed correctly. Unfortunately I still get >'phpunit' is not recognized as an internal or external command,
operable program or batch file.

I have the two variable values declared C:\wamp\bin\php\php5.3.10 and C:\wamp\www\yii\framework. Please help
Frank Naydowski said…
Klasse! Super! Vielen Dank!
James Blake said…
this might is really a nice information and i really like to see different sort of blog like this one check this php web developer
thanks for sharing..

Popular posts from this blog

Restart the Windows File Sharing Service to fix weird problems

WPF, ImageSource and Embedded Resources

SharpDevelop dark color scheme