jeroenherczeg / laravel-scout-solr

Solr Driver for Laravel Scout
http://solr-driver-for-laravel-scout.readthedocs.io
MIT License
11 stars 12 forks source link

Searchable doesn't work in tests - RuntimeException: A facade root has not been set. #11

Closed iateadonut closed 3 years ago

iateadonut commented 3 years ago

Detailed description

fresh installation of laravel 6. follow all of the implementation instructions.

Add 'use Searchable;' to the App\User model.

put $u = new User(); in a test.

run test.

get back the error:

1) SolrEngineTest::test1
RuntimeException: A facade root has not been set.

/var/www/laravel-scout-solr-iateadonut-laravel6/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:258
/var/www/laravel-scout-solr-iateadonut-laravel6/vendor/laravel/scout/src/ModelObserver.php:31
/var/www/laravel-scout-solr-iateadonut-laravel6/vendor/laravel/scout/src/Searchable.php:27
/var/www/laravel-scout-solr-iateadonut-laravel6/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:220
/var/www/laravel-scout-solr-iateadonut-laravel6/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:200
/var/www/laravel-scout-solr-iateadonut-laravel6/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:187
/var/www/laravel-scout-solr-iateadonut-laravel6/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:166
/var/www/laravel-scout-solr/tests/SolrEngineTest.php:20

You'll get this same error by running the test that comes with the package.

You do not get this error running in a route, only through a test.

Your environment

php artisan --version Laravel Framework 6.20.16

iateadonut commented 3 years ago

needed to use a Feature rather than unit test