Reputation: 931
I have a normal directory structure:
- root
- vendor
- bin/phpunit
- tests
- bootstrap.php
my composer.json:
{
"name": "test/testing",
"minimum-stability": "dev",
"require": {
"phpunit/phpunit": "4.1.*@dev",
"phpunit/phpunit-mock-objects": "2.2.*@dev"
},
"autoload": {
"classmap": ["tests/config.inc","test.inc"]
}
}
My bootstrap.php:
<?php
require_once 'vendor/autoload.php';
There is some other stuff inside the bootstrap, thats why I need it, but I removed it here because it has nothing to do with my problem.
When I try to run PHPUnit at the root folder:
vendor/bin/phpunit --bootstrap tests/bootstrap.php tests/ItemsTest.php
I get the error:
PHP Warning: require(xxxx/vendor/phpunit/phpunit-mock-objects/tests/../vendor/autoload.php): failed to open stream: No such file or directory in xxxxxxx/vendor/phpunit/phpunit-mock-objects/tests/bootstrap.php on line 4
i don´t know why phpunit/the autoloader is loading this bootstrap:
phpunit-mock-objects/tests/bootstrap.php
and of course line 4 in there:
require __DIR__ . '/../vendor/autoload.php';
does not work.
Upvotes: 2
Views: 1344
Reputation: 7941
PhpUnit does not understand the bootstrap path as relative for whatever reason.
Replacing the bootstrap path as follows seems to do the trick:
vendor/bin/phpunit --bootstrap ./tests/bootstrap.php tests/ItemsTest.php
Upvotes: 2