potentdevelopment's avatar

Config Issue When Running Unit Test

Fatal error: Uncaught ReflectionException: Class config does not exist in /app/vendor/laravel/framework/src/Illuminate/Container/Container.php:873 Stack trace: #0 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(873): ReflectionClass->__construct('config') #1 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\Container\Container->build('config') #2 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\Container\Container->resolve('config', Array) #3 /app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(119): Illuminate\Container\Container->make('config', Array) #4 /app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(275): app('config') #5 /app/app/Services/GetCylindoImage.php(23): config('cylindo.account') #6 /app/tests/Feature/CylindoImageTest.php(21): App\Services\GetCylindoImage->__construct() #7 /app/vendor/phpunit/phpunit/src/Framework/TestBuilder.php(138): Tests\Feature\CylindoImageTest->__construct() in /app/vendor/phpunit/phpunit/src/TextUI/Command.php on line 98

Hello when I run php artisan test, the error message above is what I get. I've checked my .env file to make sure there are no spaces in the values. The files all work fine when I run from the browser.

0 likes
1 reply
martinbean's avatar

@potentdevelopment Then you don’t have a unit test if it’s trying to interact with the framework.

A unit test should be testing a piece of code (i.e. a class or method) in isolation. It should not be relying on the framework, a database, or any other external resource otherwise you’re not testing a single unit of code.

Please or to participate in this conversation.