I'm working on Laravel 5.4 and trying to write the unit test to cover my function. But I got a crazy bug. Please have look at my code and help me.
Here is my test file
class UserControllerTest extends TestCase
{
use DatabaseTransactions;
protected $isCreateToken = true;
public function testViewAccountDetailWithFieldsOK()
{
$this->get('/v1.0/me');
$this->assertResponseStatus(200);
}
public function testViewAccountDetailOK()
{
$this->get('/v1.0/me');
$this->assertResponseStatus(200);
}
}
When I try to run command: phpunit
I got this error:
PHPUnit 5.7.21 by Sebastian Bergmann and contributors.
.F 2 / 2 (100%)
Time: 710 ms, Memory: 14.00MB
There was 1 failure:
1) Tests\Controller\Api\UserControllerTest::testViewAccountDetailOK
Expected status code 200, got 404.
Failed asserting that 404 matches expected 200.
/Users/johnnguyen/Workspace/Laravel/mobile/vendor/laravel/browser-kit-testing/src/Concerns/MakesHttpRequests.php:744
/Users/johnnguyen/Workspace/Laravel/mobile/tests/Controller/Api/UserControllerTest.php:24
/Users/johnnguyen/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:186
/Users/johnnguyen/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:116
But when I run separately for each function:
John-Nguyen:mobile johnnguyen$ phpunit --filter=testViewAccountDetailOK
PHPUnit 5.7.21 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 591 ms, Memory: 14.00MB
OK (1 test, 2 assertions)
2 functions are the same code.
but I got the issue 404: NotFoundHttpException
This is the first time I got this issue.
Can anyone help me for this bug?
Many thanks.