/**
  * setUp
  */
 public function setUp()
 {
     parent::setUp();
     $authorization = new AuthorizationMock($this);
     $this->authorization = $authorization->AuthorizationMockTrue();
     $this->manager = $this->getMock("ResolveAuth\\Controller\\Component\\AuthorizationComponent", ['requireResolvable', 'requireRegistered', 'getResolvable'], [], '', false);
     $this->manager->method('getResolvable')->willReturn($this->authorization);
 }
 /**
  * Test state value with FALSE or FALSE operation
  */
 public function testStateWithFalseOrFalse()
 {
     $authorization1 = $this->AuthorizationMock->AuthorizationMockFalse();
     $authorization2 = $this->AuthorizationMock->AuthorizationMockFalse();
     $authorization = new OrAuthorization();
     $authorization->initialize($this->context);
     $authorization->resolvables = [$authorization1, $authorization2];
     $this->assertFalse($authorization->state());
 }
 /**
  * Test value with unresolved authorizations
  */
 public function testValueUnresolved()
 {
     $authorizationMockTrue = $this->AuthorizationMock->AuthorizationMockUnresolved(true);
     $authorizationMockFalse = $this->AuthorizationMock->AuthorizationMockUnresolved(false);
     $authorizationTrue = new NotAuthorization();
     $authorizationTrue->initialize($this->context);
     $authorizationTrue->resolvable = $authorizationMockTrue;
     $this->assertTrue($authorizationTrue->value());
     $authorizationFalse = new NotAuthorization();
     $authorizationFalse->initialize($this->context);
     $authorizationFalse->resolvable = $authorizationMockFalse;
     $this->assertTrue($authorizationFalse->value());
 }
 /**
  * Test that check throw exception when failed
  * @expectedException \Cake\Network\Exception\UnauthorizedException
  * @expectedExceptionMessage UnauthorizedAccess
  */
 public function testCheckUnauthorized()
 {
     $this->component->startup(new Event("Controller.startup", $this->controller));
     $this->component->check($this->authorization->AuthorizationMockFalse());
 }
 /**
  * Helper method to get ContextAuthorization mock
  * @param $value
  * @return PHPUnit_Framework_MockObject_MockObject
  */
 public function getAuthorization($value)
 {
     $authorization = new AuthorizationMock($this);
     return $authorization->getAuthorization($value);
 }