I am trying to use PhpUnit with Composer. For this purpose I did:
1 Added phpunit to req composer section:
"require": { "php": ">=5.3.0" }, "require-dev": { "phpunit/phpunit": "3.7.*" }, "autoload": { "psr-0": {"PhpProject": "src/"} }
2 Installed necessary:
php composer.phar install --dev
The operation completed successfully.
Install phpunit / phpunit (3.7.6) Download: 100%
Unfortunately, when I want to run tests, I get
./vendor/bin/phpunit PHP Fatal error: call add () member function for non-object in /home/serek/php/project/tests/bootstrap.php on line 12
The problem arises because return ComposerAutoloaderInit :: getLoader (); in vendor / autoload returns NULL in the test bootstrap.
Any idea how this can be solved without hacking a loader?
code: phpunnit.xml.dist
> <?xml version="1.0" encoding="UTF-8"?> > > <phpunit bootstrap="tests/bootstrap.php" colors="true"> > <testsuites> > <testsuite name="PhpProject Test Suite"> > <directory>tests/PhpProject/</directory> > </testsuite> > </testsuites> > > <filter> > <whitelist> > <directory suffix=".php">src/PhpProject/</directory> > </whitelist> > </filter> </phpunit>
tests / bootstrap.php (I only need an autoloader here)
> $loader = require_once __DIR__ . "/../vendor/autoload.php"; > $loader->add('PhpProject\\', __DIR__);
/../seller/autoload.php
// autoload.php generated by Composer require_once __DIR__ . '/composer' . '/autoload_real.php'; return ComposerAutoloaderInit::getLoader();
php phpunit composer-php
mrok Oct 08 '12 at 23:01 2012-10-08 23:01
source share