2

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.

0

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

1 Comment

GREAT! thanks a lot! i didn´t see this between all the trees... ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.