I'm hoping this post will save someone some time.

Like every other good developer, I wanted to install phpUnit to get some 
automated testing going on Symfony2.

The phpUnit documentation tells you to use PEAR to download and install 
phpUnit with all it's dependant packages.

Unfortunately, I am stuck with a windows 7 machine, which is near impossible 
to get working properly with PEAR and phpUnit. My guess is this is due to 
the various windows 7 paths, ownerships, permissions and other stuff - and I 
just don't know windows 7 well enough to wade through it all. I know others 
have succeeded, but after several hours, literally, it still wasn't 
happening for me.

I finally gave up on PEAR for windows 7, may it rest in peace, and decided 
to do things the good old manual way, by downloading directly from github.

PHPUnit was totally working on my windows 7 box within about 20 minutes.

This is the (easy) story:

1. In the root of your webserver, create a folder called PHPUnit-Main/ at 
the same level as your Symfony project.
2. Download zips of all the nine projects phpUnit depends on (see phpUnit's 
readme on github - use the master branch of each version)


So, you have:

Symfony/
PHPUnit-Main/
      phpunit/
      dbunit/
      php-code-coverage/
      etc.

3. Add the following code to the top of the file in 
PHPUnit-Main/phpunit/phpunit.php:

$pathToPHPUnitMain = "C:\\Program Files 
(x86)\\Zend\\Apache2\\htdocs\\PHPUnit-Main\\"; // Change for your situation.
$paths = array('dbunit', 'php-code-coverage', 
'php-file-iterator','php-text-template','php-timer', 'php-token-stream', 
'phpunit', 'phpunit-mock-objects', 'phpunit-selenium');
foreach ($paths as $path){
    set_include_path(get_include_path() . PATH_SEPARATOR . 
$pathToPHPUnitMain . $path);
}

I know you can do the same with php.ini, or .htaccess, but it's done and it 
works, and I'm not sinking any more time into this.

That's it!

You can now execute the entire Symfony2 testsuite by going to the 
Symfony/app directory and doing:

php ../../PHPUnit-Main/phpunit/phpunit.php


It is an exercise left to the readers to shorten the command above to your 
liking.

Hope this helps someone.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to