Created
December 2, 2016 06:00
-
-
Save jarektkaczyk/055eefc4da2949c517c140160bc50919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// controller | |
$course = Course::with(...)->checkEstablishmentOnView()->excludeArchived()->findOrFail($id); | |
$view = View::make('some.view')->with('course', $course); | |
return response()->json(['html' => $view->render()]); | |
// kahlan spec | |
it('does some magic and unicorns and all that stuff', function () { | |
allow(Double::classname(['class' => App\Course::class]))->toReceive('::with')->andReturn($query = Double::instance()); | |
allow($query)->toReceive('checkEstablishmentOnView->excludeArchived->findOrFail')->andReturn('your model here'); | |
allow(Double::classname(['class' => 'View']))->toReceive('::make')->with('some/partial/view')->andReturn($view = Double::instance()); | |
allow($view)->toReceive('with')->andReturn($view); | |
allow($view)->toReceive('render')->andReturn('view contents'); | |
$this->laravel->get('testing/1')->seeJsonContains(['html' => 'view contents'])->assertResponseOk(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment