Skip to main content

PHPUnit from sources in WAMPServer and NetBeans

Tutorial how to install PHPUnit in WAMPServer on Windows and how to make it working in NetBeans 7.1


Disclaimer: If You can use PEAR it would be much easier! :)


1: Install WAMPServer: http://www.wampserver.com/

2: Checkout repositories mentioned at the bottom of page: https://github.com/sebastianbergmann/phpunit

I created folder "includes" in PHP directory.

mkdir phpunit && cd phpunit
git clone git://github.com/sebastianbergmann/phpunit.git
git clone git://github.com/sebastianbergmann/dbunit.git
git clone git://github.com/sebastianbergmann/php-file-iterator.git
git clone git://github.com/sebastianbergmann/php-text-template.git
git clone git://github.com/sebastianbergmann/php-code-coverage.git
git clone git://github.com/sebastianbergmann/php-token-stream.git
git clone git://github.com/sebastianbergmann/php-timer.git
git clone git://github.com/sebastianbergmann/phpunit-mock-objects.git
git clone git://github.com/sebastianbergmann/phpunit-selenium.git
git clone git://github.com/sebastianbergmann/phpunit-story.git
git clone git://github.com/sebastianbergmann/php-invoker.git


 I also check out branches (mostly 1.1) of this repositories.

Add all of this directories to php include_path (note that WAMP has two php.ini files, one in PHP directory, and one in APACHE, this in php directory is obligatory.

For me it looks:
 include_path = ".;C:\wamp\bin\php\php5.3.8\includes\phpunit;C:\wamp\bin\php\php5.3.8\includes\php-file-iterator;C:\wamp\bin\php\php5.3.8\includes\php-code-coverage;C:\wamp\bin\php\php5.3.8\includes\php-token-stream;C:\wamp\bin\php\php5.3.8\includes\php-text-template;C:\wamp\bin\php\php5.3.8\includes\php-timer;C:\wamp\bin\php\php5.3.8\includes\phpunit-mock-objects"


Make it work in NetBeans

NetBeans usess phpunit.bat to get version (but without pear there is no version...)

First fix phpunit.bat to have proper php paths (I doesn't have PHP in PATH so this might be optional)


if "%PHPBIN%" == "" set PHPBIN="C:\wamp\bin\php\php5.3.8\php.exe"
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "C:\wamp\bin\php\php5.3.8\inludes\phpunit\phpunit.php" %*


Thanks to this phpunit is for me properly executed.


Second: edit PHPUnit/Runner/Version file and just write your version.



class PHPUnit_Runner_Version
{
    /**
     * Returns the current version of PHPUnit.
     *
     * @return string
     */
    public static function id()
    {
        return '3.6.0';
    }

    /**
     * @return string
     */
    public static function getVersionString()
    {
        return 'PHPUnit 3.6.0 by Sebastian Bergmann.';
    }
}


Test
To test I created Class in Test folder (just create folder "tests" in project and in project properties select it as  "Test folder")


<?php
class DummyTest extends PHPUnit_Framework_TestCase
{   
    public function testToString()
    {
        
        $this->assertEquals('MyString', 'MyString');
    }
}






Comments

Popular posts from this blog

Course Review: The Bitfountain iOS 8 with Swift Immersive

This is second big iOS learning project. For first one read iOS Programming book review. As I only have two of them done I have to compare them somehow.

I am mindful that it took me a really long time to finish it (since last autumn). For a couple of months this year I didn't even have the internet to learn it, so it could not be helped. But last half of the June I've spent watching the videos every day and managed to finish it before any new internet problems.

So how was it?
In my opinion, it's great if you're starting out. There are a lot of basics, and seeing how to do things in XCode just makes your learning much easier than looking at the photos in the book. On the other hand, learning is more shallow and it is much easier to just follow the videos and learn only the basics without bigger picture about iOS SDK. I somehow missed more challenging exercises (even though I don't like to do them ;)

Length:
Course it pretty long but many videos are quite short (1-2…

How to Learn when Life is Short

I haven't really think this through but I have read really interesting articles recently and I just wanted to write for myself later.

Life is Short by Paul Graham

It's just that, learn from people older that you what is most important, and that life actually is short...

Instead of Goals or Resolutions, Try Creating Rules by Leo Babuta

In the time of New Year Resolutions, it's good to read something that is proposing different way of achieving things. Still I see much more value in habits than setting goals. But...

The Easy Way To Learn Hard Stuff by Per Harald Borgen
It's something that I read from time to time and I know it works sometimes for me. The things I learn then are really learned and something Jakub Wasilewski  has told me many times to do. Still it's uncomfortable and for some reason, I have failed to use this method more than once or twice. Writing it here so maybe I can think about it more and figure out how to do that more often.

Towards an understandin…