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
Post a Comment
Comments: