Posts Tagged ‘phpunit’

PHPUnit on OSX Lion CLI

Saturday, November 10th, 2012 | Programming, Tech

If you’re trying to run PHPUnit from the terminal in Mac OSX Lion, you may get an error similar to the following.

File/Iterator/Autoload.php failed to open stream

You can resolve this by running the following commands.

curl http://pear.php.net/go-pear.phar > go-pear.php
sudo php -q go-pear.php

PHPUnit should now run without errors (or at least, without errors in their code 😉 ).

PHPUnit and PEAR packages break on Mountain Lion

Monday, August 6th, 2012 | Programming, Tech

If you have recently upgraded to Mac OS X Mountain Lion (10.8) you may find that PHPUnit and other PEAR packages no longer work. You may get errors similar to the following.

PHP Copy & Paste Detector

Warning: require(PHPCPD/Autoload.php): failed to open stream: No such file or directory in /Users/chris/pear/bin/phpcpd on line 49

Fatal error: require(): Failed opening required 'PHPCPD/Autoload.php' (include_path='.:') in /Users/chris/pear/bin/phpcpd on line 49

PHP Mess Detector

Warning: require_once(PHP/PMD/TextUI/Command.php): failed to open stream: No such file or directory in /Users/chris/pear/bin/phpmd on line 38

Fatal error: require_once(): Failed opening required 'PHP/PMD/TextUI/Command.php' (include_path='.:') in /Users/chris/pear/bin/phpmd on line 38

Unfortunately, there doesn’t seem to be an easy way to fix them, other then by reinstalling each package.

sudo pear install --force --alldeps phpunit/phpunit
sudo pear install --force --alldeps phpmd/PHP_PMD

The tools should then run as expected.

Install dev packages with Composer

Monday, April 2nd, 2012 | Programming, Tech

Sometimes, you might install your dependencies via composer but find that the tests don’t work for it. You could get an error similar to the following.

phpunit
PHP Fatal error:  Class 'Symfony\Component\Yaml\Yaml' not found in
/home/example/Gherkin/src/Behat/Gherkin/Keywords/CucumberKeywords.php on line 31

This could be because if you have just run composer install, it will only install the main packages, but some packages could be specified as dev only. You may find a “require-dev” section in the composer.json file.

If you do, you can install the packages using the following flag.

composer install --dev

This will install the development packages as well, which should allow you to run the tests.