0

This is similar this SO question, but it is manifesting with composer instead of pear.

My relevant composer.json lines:

"require-dev": {
    "phpunit/phpunit": "3.7.14",
    "symfony/browser-kit": ">=2.3,<2.4-dev"
},

Create this include_paths.php file in vendor/composer:

return array(
    $vendorDir . '/phpunit/phpunit-mock-objects',
    $vendorDir . '/phpunit/php-timer',
    $vendorDir . '/phpunit/php-token-stream',
    $vendorDir . '/phpunit/php-code-coverage',
    $vendorDir . '/phpunit/phpunit',
    $vendorDir . '/symfony/yaml',
);

Running "php vendor/bin/phpunit" triggers the error:

PHPUnit_Framework_Exception: PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /path/to/project/vendor/phpunit/phpunit/PHPUnit/Autoload.php on line 45

I can fix the problem by manually adding the missing include path into the array like:

$vendorDir . '/phpunit/php-file-iterator',

But that will disappear the next time I run Composer.

I'm guessing I have an error in my composer.json, but I can't really think of what it is.

Community
  • 1
  • 1
Parris Varney
  • 11,320
  • 12
  • 47
  • 76
  • Is there a reason for using such an old 3.7 version of PHPUnit? Have you tried the most recent 3.7.37? – Sven Sep 10 '14 at 01:00
  • I just tried your composer.json and it works like a charm. Do you have a custom phpunit configuration in your project? I'm guessing you overrode the autoloader. – Jakub Zalas Sep 10 '14 at 11:59
  • @JakubZalas I do, and I did, but the boostrap file calls `vendor/autoload.php`. The only other thing it does is a chdir(), maybe that is the issue, thanks for the comment. – Parris Varney Sep 10 '14 at 15:52
  • @Sven It looks like 3.7.37 did the trick. If you want to move your comment to an answer, I'll accept it for future visitors. – Parris Varney Sep 10 '14 at 15:56

1 Answers1

1

I suggest updating to the most recent 3.7 PHPUnit. Doing this with Composer is easy, just require 3.7.* to allow future updates of that version (although it is unlikely they will happen because development of PHPUnit currently is maintaining 4.2, stabilizing 4.3 and working on 4.4).

Comparing the success between using PHPUnit 3.7.14 and the more recent 3.7.37, it is likely that some internal bugfixes within PHPUnit fix the problem.

Sven
  • 69,403
  • 10
  • 107
  • 109