public function testShouldLoadAndAuthorizeUsingCustomInstanceName()
{
$projectAttributes = ['id' => 2];
$project = $this->buildModel('Project', $projectAttributes);
$this->params = array_merge($this->params, array_merge(['action' => 'show', 'id' => $project->id]));
$this->controller->shouldReceive('authorize')->once()->with('show', $project)->andThrow('Efficiently\\AuthorityController\\Exceptions\\AccessDenied');
$resource = new Efficiently\AuthorityController\ControllerResource($this->controller, ['instanceName' => 'customProject']);
try {
$resource->loadAndAuthorizeResource();
} catch (Efficiently\AuthorityController\Exceptions\AccessDenied $e) {
$this->assertEquals($this->getProperty($this->controller, 'customProject'), $project);
return;
// see http://phpunit.de/manual/3.7/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.exceptions.examples.ExceptionTest4.php
}
$this->fail('An expected exception has not been raised.');
}