示例#1
0
文件: Group.php 项目: rukzuk/rukzuk
 /**
  * @param  string $right
  * @param  arrray $nonAllowedAreas
  * @return boolean
  */
 private function validateRight($right, array $nonAllowedAreas = array())
 {
     $rightValidator = new UserRightValidator($nonAllowedAreas);
     if (!$rightValidator->isValid($right)) {
         $messages = array_values($rightValidator->getMessages());
         $this->addError(new Error('right', json_encode($right), $messages));
         return false;
     }
     return true;
 }
示例#2
0
 /**
  * @test
  * @group small
  * @group dev
  * @group library
  */
 public function isValidShouldReturnFalseForInvalidIdsIds()
 {
     $value = array('area' => 'pages', 'privilege' => 'subEdit', 'ids' => array('ALBUM-be1ecf03-acc4-4fdb-add4-72ebb0878006-ALBUM', 'USER-be1ecf03-acc4-4fdb-add4-72ebb0878006-USER'));
     $value = new \stdClass();
     $value->area = 'pages';
     $value->privilege = 'subEdit';
     $value->ids = array('ALBUM-be1ecf03-acc4-4fdb-add4-72ebb0878006-ALBUM', 'USER-be1ecf03-acc4-4fdb-add4-72ebb0878006-USER');
     $rightValidator = new UserRightValidator();
     $this->assertFalse($rightValidator->isValid($value));
     $validationErrors = $rightValidator->getErrors();
     $this->assertSame(1, count($validationErrors));
     $this->assertSame(UserRightValidator::INVALID_IDS_PAGE_ID, $validationErrors[0]);
 }