/** * @test * @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException */ function it_throws_an_exception_when_firstorfail_does_not_find_anything() { // make sure we won't find anything $mockCriteria = $this->makeMockCriteria($this->exactly(1), 'MockCriteria', function ($query) { return $query->where('name', 'some name that certainly does not exist'); }); $this->repository->pushCriteria($mockCriteria); $this->repository->firstOrFail(); }