2

I am just testing my laravel app with phpunit When i run vendor/bin/phpunit i am getting error like below Error: Call to undefined method ExampleTest::assertStatus()

Below is the code i was trying to execute

$response = $this->json('POST', '/users', ['customer_name' => 'Ratke-Harris']);

        $response
            ->assertStatus(200)
            ->assertExactJson([
                'created' => true,
            ]);

As per the laravel docs , even there they have mentioned the same example. I don't understand why it is throwing error.

Any ideas ? Please.

2 Answers 2

4

Change ->assertStatus(200) to ->assertResponseStatus(200)

Sign up to request clarification or add additional context in comments.

1 Comment

this is the right answer. There appears to be an error in their documentation: laravel.com/docs/5.4/http-tests
0

Just change use PHPUnit\Framework\TestCase with use Tests\TestCase in the top of your test class:))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.