You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
840 B

<?php
namespace Tests\iLaravel\Policies;
use App\Models\ILaravel;
use Tests\Bootstrap;
class CustomMethodPolicyTest extends Bootstrap
{
function test_custom_method_policy_successful()
{
$this->modelWithPolicy('ilaravels', ['model:policyCheckCustom'])
->getJson(route('api.ilaravels.show', $this->one(ILaravel::class)))
->assertOk();
}
public function test_custom_method_policy_fail()
{
$mokModel = $this->mockModel(ILaravel::class);
$mokModel->shouldReceive('resolveRouteBinding')->andReturnSelf();
$mokModel->shouldReceive('policyCheckCustom')->andReturnFalse();
$this->modelWithPolicy('ilaravels', ['model:policyCheckCustom'])
->getJson(route('api.ilaravels.show', $this->one(ILaravel::class)))
->assertForbidden();
}
}