Testing Repositories

class ExampleTest extends TestCase
{
    public function testBasicTest()
    {
        UserRepository::partialMock()
            ->shouldReceive('index')
            ->andReturn(['data' => [],]);

        $this->withHeader('Accept', 'application/json')
            ->get('/api/restify/users')
            ->assertJsonStructure([
                'response' => 'data',
            ])->assertOk();
    }
}

So you can use the partialMock to get the partial mock instance of the repository, and then perform actions or expectations over it.

Edit this page on GitHub Updated at Sun, Aug 13, 2023