Getting below error, while running "phpunit" on my lumen project root folder.
There was 1 error:
ExampleTest::testBasicExample
ErrorException: Cannot redeclare class JWTAuth
..bootstrapapp.php:29
..testsTestCase.php:12
..vendorlaravellumen-frameworksrcTestingApplicationTrait.php:35
..vendorlaravellumen-frameworksrcTestingTestCase.php:43
JWTAuth
Unrelated to Lumen.
@cvinothkumar : probably your app.php has a class_alias or something like that. The problem with TestCase is that it reloads the app object including its app.php. That means: check if class_exists before class_alias. Somehting like this:
if (!class_exists('Config')) {
class_alias(Config::class, 'Config');
}
@catalinux Thanks a lot!
Most helpful comment
@cvinothkumar : probably your app.php has a class_alias or something like that. The problem with TestCase is that it reloads the app object including its app.php. That means: check if class_exists before class_alias. Somehting like this: