Reputation: 173
I wrote the test:
$response = $this->get('/something');
$response->assertStatus(200);
It displays this error:
Error: Call to undefined method Tests\Unit\SomeTest::assertStatus()
I found how I can fix my problem (code is below) but I want to use first method:
$response = $this->get('/something');
$this->assertEquals(200, $this->response->status());
Why doesn't the first code work?
Upvotes: 14
Views: 9951
Reputation: 18926
Instead of using the TestCase
class PHPUnit\Framework\TestCase
you should use Tests\TestCase
. The following snippet should work.
use Tests\TestCase;
class ControllerTest extends TestCase
Upvotes: 10
Reputation: 65
Use this following code:
namespace Tests\Unit;
use Tests\TestCase;
class SampleTest extends TestCase{
//your code
}
Upvotes: 1
Reputation: 1111
I solved it by changing use PHPUnit\Framework\TestCase
to use Tests\TestCase
.
Upvotes: 20