Returns registered information.
public getInformation ( ) : array | ||
Результат | array |
/** * @covers eZ\Publish\Core\MVC\Symfony\Security\User\Identity::__construct * @covers eZ\Publish\Core\MVC\Symfony\Security\User\Identity::setInformation * @covers eZ\Publish\Core\MVC\Symfony\Security\User\Identity::getInformation */ public function testSetInformation() { $identity = new Identity(); $this->assertSame(array(), $identity->getInformation()); $info = array('foo' => 'bar', 'truc' => 'muche', 'number' => 123); foreach ($info as $name => $value) { $identity->setInformation($name, $value); } $this->assertSame($info, $identity->getInformation()); }
/** * @covers eZ\Publish\Core\MVC\Symfony\Security\User\IdentityDefiner\Role::__construct * @covers eZ\Publish\Core\MVC\Symfony\Security\User\IdentityDefiner\Role::setIdentity */ public function testSetIdentity() { $user = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\User'); $identity = new Identity(); $this->repositoryMock->expects($this->once())->method('getCurrentUser')->will($this->returnValue($user)); $roleId1 = 123; $roleId2 = 456; $roleId3 = 789; $limitationForRole2 = $this->generateLimitationMock(array('limitationValues' => array('/1/2', '/1/2/43'))); $limitationForRole3 = $this->generateLimitationMock(array('limitationValues' => array('foo', 'bar'))); $returnedRoleAssignments = array($this->generateRoleAssignmentMock(array('role' => $this->generateRoleMock(array('id' => $roleId1)))), $this->generateRoleAssignmentMock(array('role' => $this->generateRoleMock(array('id' => $roleId2)), 'limitation' => $limitationForRole2)), $this->generateRoleAssignmentMock(array('role' => $this->generateRoleMock(array('id' => $roleId3)), 'limitation' => $limitationForRole3))); $this->roleServiceMock->expects($this->once())->method('getRoleAssignmentsForUser')->with($user, true)->will($this->returnValue($returnedRoleAssignments)); $this->assertSame(array(), $identity->getInformation()); $definer = new RoleDefiner($this->repositoryMock); $definer->setIdentity($identity); $identityInfo = $identity->getInformation(); $this->assertArrayHasKey('roleIdList', $identityInfo); $this->assertSame("{$roleId1}|{$roleId2}|{$roleId3}", $identityInfo['roleIdList']); $this->assertArrayHasKey('roleLimitationList', $identityInfo); $limitationIdentifierForRole2 = get_class($limitationForRole2); $limitationIdentifierForRole3 = get_class($limitationForRole3); $this->assertSame("{$roleId2}-{$limitationIdentifierForRole2}:/1/2|/1/2/43,{$roleId3}-{$limitationIdentifierForRole3}:foo|bar", $identityInfo['roleLimitationList']); }