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.

06011991
  • 797
  • 2
  • 13
  • 39

2 Answers2

4

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

  • this is the right answer. There appears to be an error in their documentation: https://laravel.com/docs/5.4/http-tests – JP Lew Apr 13 '18 at 17:33
0

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

akbar
  • 625
  • 6
  • 12