コード例 #1
0
ファイル: PermissionsTest.php プロジェクト: utrenkner/YAWIK
 /**
  * Tests if getFrom returns correct value.
  *
  */
 public function testGetFromReturnsCorrectPermission()
 {
     $grantedResource = $this->getMockBuilder('\\Core\\Entity\\PermissionsResourceInterface')->getMockForAbstractClass();
     $grantedResource->expects($this->atLeastOnce())->method('getPermissionsUserIds')->will($this->onConsecutiveCalls(array('all' => array('user1', 'user2'), 'view' => array('popel', 'dopel')), array('all' => array('user3'))));
     $grantedResource->method('getPermissionsResourceId')->willReturn('grantResource');
     $ungrantedResource = $this->getMockBuilder('\\Core\\Entity\\PermissionsResourceInterface')->getMockForAbstractClass();
     $ungrantedResource->method('getPermissionsResourceId')->willReturn('ungrant');
     $target = new Permissions();
     $target->grant($grantedResource, PermissionsInterface::PERMISSION_ALL);
     $this->assertEquals(PermissionsInterface::PERMISSION_NONE, $target->getFrom($ungrantedResource));
     $this->assertEquals(null, $target->getFrom($grantedResource));
     $target->grant($grantedResource, PermissionsInterface::PERMISSION_CHANGE);
     $this->assertEquals(PermissionsInterface::PERMISSION_ALL, $target->getFrom($grantedResource));
 }
コード例 #2
0
ファイル: Application.php プロジェクト: vfulco/YAWIK
 /**
  * {@inheritDoc}
  * @see \Core\Entity\PermissionsAwareInterface::getPermissions()
  */
 public function getPermissions()
 {
     if (!$this->permissions) {
         $permissions = new Permissions('Application');
         if ($this->user) {
             $permissions->grant($this->user, Permissions::PERMISSION_ALL);
         }
         $this->setPermissions($permissions);
     }
     return $this->permissions;
 }
コード例 #3
0
 public function getPermissions()
 {
     if (!$this->permissions) {
         $perms = new Permissions();
         if ($this->user instanceof UserInterface) {
             $perms->grant($this->user, PermissionsInterface::PERMISSION_ALL);
         }
         $this->setPermissions($perms);
     }
     return $this->permissions;
 }