/** * Apply resource ownership * * @return boolean */ protected function applyForResource() { if (is_null($this->resource)) { return true; } return $this->resource->isBelongsTo($this->user); }
function it_can_check_for_resource_owner(User $user, Resource $resource) { $resource->isBelongsTo($user)->shouldBeCalled()->willReturn(false); $user->abilities()->shouldBeCalled()->willReturn(['update']); $this->forResource($resource)->check('update')->shouldEqual(false); }