I've just installed Laravel 5 and run composer install (composer 1.0.0-dev), which installed phpunit in vendor/bin/phpunit.
When I run vendor/bin/phpunit I get this message:
You need to set up the project dependencies using the following commands:
The autoload.php file is in vendor/autoload.php.
PHPunit is searching for autoload.php in the wrong folder:
https://github.com/sebastianbergmann/phpunit/blob/4a9fb9c9d7f980b00da53eb809d82f9f1a9fe56b/phpunit#L16
This can be fixed by simply as adding __DIR__ . '/../autoload.php' into the array in the foreach.
Which platform are you using? Sounds like this is possibly the same as #1516.
I'm on OSX Yosemite. __DIR__ resolves as vendor/bin but that's correct because the files are in:
vendor/bin/phpunit
vendor/autoload.php
To resolve the issue in my project I added __DIR__ . '/../autoload.php' to the array.
Is vendor/bin/phpunit not a symlink on your system? For me it looks like this:
$ ls -lo vendor/bin/phpunit
lrwxr-xr-x 1 jeff 26 Feb 11 18:11 vendor/bin/phpunit -> ../phpunit/phpunit/phpunit
Not a symlink.
$ ls -lo vendor/bin/phpunit
-rwxr-xr-x 1 federico 960 Feb 11 17:45 vendor/bin/phpunit
FYI this is the composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
I've found the solution. phpunit from vendor/bin isn't symlinked. You can fix it by re-installing (remove from composer.json, composer update, add to composer.json, composer update) phpunit
I had the same problem - phpunit wasn't symlinked. Following the steps above by @bart fixed it. Cheers!
Many thanks to @bart - same issue!
I was able to solve it without a complete reinstall. Just:
rm -f vendor/bin/phpunit
ln -s ../vendor/phpunit/phpunit/phpunit vendor/bin/phpunit
I was able to solve it without a complete reinstall. Just:
rm -f vendor/bin/phpunit ln -s ../vendor/phpunit/phpunit/phpunit vendor/bin/phpunit
The path should be:
ln -s ../phpunit/phpunit/phpunit vendor/bin/phpunit
This worked for me:
rm -rf vendor
composer install
Most helpful comment
I've found the solution. phpunit from vendor/bin isn't symlinked. You can fix it by re-installing (remove from composer.json, composer update, add to composer.json, composer update) phpunit