Пример #1
0
 /**
  * @covers \BjyAuthorize\Controller\Plugin\IsAllowed
  */
 public function testIsAllowed()
 {
     $authorize = $this->getMock('BjyAuthorize\\Service\\Authorize', array(), array(), '', false);
     $authorize->expects($this->once())->method('isAllowed')->with('test', 'privilege')->will($this->returnValue(true));
     $plugin = new IsAllowed($authorize);
     $this->assertTrue($plugin->__invoke('test', 'privilege'));
     $this->assertSame($authorize, $plugin->getAuthorizeService());
     $authorize2 = $this->getMock('BjyAuthorize\\Service\\Authorize', array(), array(), '', false);
     $authorize2->expects($this->once())->method('isAllowed')->with('test2', 'privilege2')->will($this->returnValue(false));
     $plugin->setAuthorizeService($authorize2);
     $this->assertSame($authorize2, $plugin->getAuthorizeService());
     $this->assertFalse($plugin->__invoke('test2', 'privilege2'));
 }