jeudi 27 août 2015

How to mock Form Request on Laravel 5.1?

We are implementing resource ownership and/or input validations through the use of FormRequest. Our controller tests are functional test so we don't mock Request but use the $this->call($method, $url, $params, ...).

The issue is that FormRequest is a subclass of Request. Is there a way to mock only the authorize() method but keeping the rest of the Request object non-mocked?

If so, how to? I already tried partial mocking with Mockery and it either didn't work or I did it wrong.

$this->mock(\Namespace\Http\Requests\CustomRequest::class . '[authorize]')
    ->shouldReceive('authorize')
    -> .......



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1WUTcB4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire