Parris Varney
Parris Varney

Reputation: 11478

Composer not creating all needed phpunit include paths

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.

Upvotes: 0

Views: 673

Answers (1)

Sven
Sven

Reputation: 70863

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.

Upvotes: 1

Related Questions