Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit test throwing ErrorException: Cannot redeclare class JWTAuth #276

Closed
cvinothkumar opened this issue Nov 3, 2015 · 3 comments
Closed

Comments

@cvinothkumar
Copy link

Getting below error, while running "phpunit" on my lumen project root folder.

There was 1 error:
ExampleTest::testBasicExample
ErrorException: Cannot redeclare class JWTAuth

..\bootstrap\app.php:29
..\tests\TestCase.php:12
..\vendor\laravel\lumen-framework\src\Testing\ApplicationTrait.php:35
..\vendor\laravel\lumen-framework\src\Testing\TestCase.php:43

@GrahamCampbell
Copy link
Member

JWTAuth

Unrelated to Lumen.

@catalinux
Copy link

@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');
}

@djordn
Copy link

djordn commented Jul 20, 2017

@catalinux Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants