jean_reptile's avatar

Problem with Unit Test

Hello,

I have a problem with Unit Test in Lumen.

When I launch phpunit I have this error :

ErrorException: Cannot redeclare class View /Applications/MAMP/htdocs/PHPTwitterAPI/bootstrap/app.php:25

In my app.php at line 25 I have : class_alias('Illuminate\Support\Facades\View', 'View'); I removed this line and replaced it with use Illuminate\Support\Facades\View;in the proper file.

But then I have this error :

ErrorException: Constant MY_CONSTANT already defined

So, it seems that my bootstrap/app.php is launched twice. But I don't find a way to resolve my problemr

0 likes
3 replies
fesja's avatar

The same is happening to me since I updated this morning. I currently have "laravel/lumen-framework": "v5.0.10"

cvinothkumar's avatar

Did you find any solution for the above issue? I'm 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

RuggedMan's avatar

Try this!

if (!class_exists('JWTAuth')) {
    class_alias('Tymon\JWTAuth\Facades\JWTAuth', 'JWTAuth');
}

Please or to participate in this conversation.