/** * @test * @group library */ public function isValidShouldReturnFalseForEmptyPagePrivilege() { $pageWithEmptyPrevilege = array('PAGE-0db7eaa7-7fc5-464a-bd47-16b3b8af00af-PAGE' => array('edit'), 'PAGE-0db7eaa7-7fc5-464a-bd47-16b3b8af00ag-PAGE' => array()); $pageWithEmptyPrevilegeJsonString = json_encode($pageWithEmptyPrevilege); $pageWithEmptyPrevilegeObject = json_decode($pageWithEmptyPrevilegeJsonString); $rightsValidator = new PageRightsValidator(); $this->assertFalse($rightsValidator->isValid($pageWithEmptyPrevilegeObject)); $validationErrors = $rightsValidator->getErrors(); $this->assertSame(1, count($validationErrors)); $this->assertSame(PageRightsValidator::INVALID_EMPTY_PRIVILEGE, $validationErrors[0]); }
/** * @param array $rights * @return boolean */ private function validatePageRights($rights) { $rightsValidator = new PageRightsValidator(); if (!$rightsValidator->isValid($rights)) { $messages = array_values($rightsValidator->getMessages()); $this->addError(new Error('rights', json_encode($rights), $messages)); return false; } return true; }