Doesn't work with phpunit installed from composer
mougrim opened this issue · 3 comments
mougrim commented
If you use composer and composer's autoloader, then soft-mocks can't rewrite composer auto loader.
It happens, because command phpunit requre's composer auto loader, see https://github.com/sebastianbergmann/phpunit/blob/5.6/phpunit.
For fix it, you can add custom phpunit command, for example:
#!/usr/bin/env php
<?php
if (version_compare('5.6.0', PHP_VERSION, '>')) {
fwrite(
STDERR,
'This version of PHPUnit requires PHP 5.6; using the latest version of PHP is highly recommended.' . PHP_EOL
);
die(1);
}
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}
// soft-mocks bootstrap
require_once dirname(__DIR__) .'/src/bootstrap.php';
\QA\SoftMocks::setPhpunitPath('/vendor/phpunit/');
// require composer autoloader
define('PHPUNIT_COMPOSER_INSTALL', \QA\SoftMocks::rewrite(dirname(dirname(__DIR__)) . '/autoload.php'));
require_once \QA\SoftMocks::rewrite(dirname(dirname(__DIR__)) . '/autoload.php');
PHPUnit_TextUI_Command::main();
Please, add this command and/or update documentation.
eelf commented
mougrim commented
Yes, it's fixed now.