Trait 'Tests\CreatesApplication' not found in ../tests/DuskTestCase.php on line 11
Assuming you have the class in the correct namespace, composer dump-autoload might help.
nope.
i've tried to find it in all codebase of dusk. looks like it just does not exist.
Ah, you need to manually add it if you upgraded from <5.4 to 5.4. Take a look at the develop branch of laravel/laravel. This is the file.
ok. got it. it works.
i think it should be mentioned in upgrade guide :)
thank you.
I agree. You can create a pull request to laravel/docs but maybe there is a better solution than copying all needed files. Upgrade guide says you don't need to rewrite all your existing tests in order to run them, but it doesn't say how to integrate Dusk with them.
@taylorotwell I will be thankful for your opinion on this subject, because soon I too will be upgrading couple of apps to 5.4.
i think for now that only thing is missing from the docs is creating that trait. all the rest worked fine.
To me 2 things were missing from 5.3 to 5.4:
In composer.json:
"Tests\\": "tests/" in "autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Tests\\": "tests/"
}
},
"phpunit/phpunit": "~4.0", by "phpunit/phpunit": "~5.0",Thanks for you reply @djaiss! This is really missing in the docs!
@djaiss For performance reasons, avoid autoloading your tests in production. You can use autoload-dev instead, as in the Laravel 5.4 repo (https://github.com/laravel/laravel/blob/master/composer.json):
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
https://getcomposer.org/doc/04-schema.md#autoload-dev:
Classes needed to run the test suite should not be included in the main autoload rules to avoid polluting the autoloader in production and when other people use your package as a dependency.
there is a 'Miscellaneous' section at the bottom of the upgrade guide that I added, that suggests you look at the comparison of the laravel/laravel repository between the current version and the previous. If you follow that you'll pick up on all these random changes.
Thanks @nlocascio @browner12 for your reply.
Can this be closed?
composer dump-autoload
To me 2 things were missing from 5.3 to 5.4:
In
composer.json:
- add
"Tests\\": "tests/"in"autoload": { "classmap": [ "database" ], "psr-4": { "App\\": "app/", "Tests\\": "tests/" } },
- replace
"phpunit/phpunit": "~4.0",by"phpunit/phpunit": "~5.0",
It worked. After updating the composer.json file you would need to run command
composer du -o
Most helpful comment
To me 2 things were missing from 5.3 to 5.4:
In
composer.json:"Tests\\": "tests/"in"phpunit/phpunit": "~4.0",by"phpunit/phpunit": "~5.0",