Lumen-framework: PHPUnit test throwing ErrorException: Cannot redeclare class JWTAuth

Created on 3 Nov 2015  路  3Comments  路  Source: laravel/lumen-framework

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

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:

if (!class_exists('Config')) {
    class_alias(Config::class, 'Config');
}

All 3 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hamihaa picture hamihaa  路  3Comments

concept47 picture concept47  路  3Comments

patrikengborg picture patrikengborg  路  3Comments

rmblstrp picture rmblstrp  路  5Comments

Andrei-Vakulski picture Andrei-Vakulski  路  3Comments