Reputation: 33
(I know you may think this is a duplicate question but I really believe its not)
I am working on an API using Laravel and I had the code all sorted out and running. However out of the blues I run my test on day and I get
ReflectionException: Class config does not exist
whenever I try to store a new Model I updated Laravel to 5.7 but the problem persisted Then I thought this was a problem with the Database but
php artisan migrate
creates database tables successfully. Running out of time.
Upvotes: 1
Views: 5355
Reputation: 5618
1- You did not extend base test class TestCase
:
class MyTest extends Illuminate\Foundation\Testing\TestCase// <---
{
// Tests
}
2- In your base test class you did not include CreatesApplication
trait:
class TestCase extends BaseTestCase
{
use CreatesApplication; // <---
// Abstract methods.
}
3- You are initializing stuff in PHPUnit's setUpBeforeClass()
or tearDown()
methods! So remove them.
4- You are using PHP's GC in your tests: gc_collect_cycles()
so remove it.
5- Clear all caches:
php artisan optimize:clear
php artisan clear-compiled
Upvotes: 0
Reputation: 742
Deleting files in the project/bootstrap/cache/
and then running:
$php artisan clear-compiled
solved my problem!
Upvotes: 0
Reputation: 1
For me the issue was with the dependencies. What worked for me was to completely remove the vendor directory and do a composer update to re-install the dependencies and vendor packages.
Upvotes: 0
Reputation: 408
The issue seems to be with phpunit 6.0:
https://github.com/laravel/dusk/issues/99
I suggest upgrading to php7.x and the latest phpunit. (I know. A pain, but there are great tutorials out there for the upgrade and if you follow them step by step, you will have it done in under a half hour.)
Upvotes: 0
Reputation: 5386
Try
php artisan clear-compiled
If it does not solve the issue then read this thread https://github.com/laravel/dusk/issues/99 and https://github.com/laravel/framework/issues/9733
Upvotes: 1