Example #1
0
 public function getControllerPluginConfig()
 {
     return array('factories' => array('isAllowed' => function ($sm) {
         $sm = $sm->getServiceLocator();
         // get the main SM instance
         $helper = new Controller\Plugin\IsAllowed();
         $helper->setAuthorizeService($sm->get('BjyAuthorize\\Service\\Authorize'));
         return $helper;
     }));
 }
Example #2
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'));
     $authorize2 = $this->getMock('BjyAuthorize\\Service\\Authorize', array(), array(), '', false);
     $authorize2->expects($this->once())->method('isAllowed')->with('test2', 'privilege2')->will($this->returnValue(false));
     $plugin = new IsAllowed($authorize2);
     $this->assertFalse($plugin->__invoke('test2', 'privilege2'));
 }