Пример #1
0
 public function testAddUserBusinessUnitBelongToDifferentOrganizations()
 {
     $tree = new OwnerTree();
     $tree->addUser('user', null);
     $tree->addBusinessUnit('bu1', null);
     $this->assertNull($tree->getBusinessUnitOrganizationId('bu1'));
     $tree->addBusinessUnit('bu2', 'org2');
     $this->assertEquals('org2', $tree->getBusinessUnitOrganizationId('bu2'));
     $tree->addBusinessUnit('bu3', 'org3');
     $this->assertEquals('org3', $tree->getBusinessUnitOrganizationId('bu3'));
     $tree->addUserBusinessUnit('user', null, null);
     $this->assertEquals(array(), $tree->getUserBusinessUnitIds('user'));
     $this->assertNull($tree->getUserOrganizationId('user'));
     $this->assertEquals(array(), $tree->getUserOrganizationIds('user'));
     $this->assertEquals(array(), $tree->getUserSubordinateBusinessUnitIds('user', 'org1'));
     $this->assertEquals(array(), $tree->getBusinessUnitsIdByUserOrganizations('user'));
     $tree->addUserBusinessUnit('user', 'org1', 'bu1');
     $this->assertEquals(array('bu1'), $tree->getUserBusinessUnitIds('user'));
     $this->assertNull($tree->getUserOrganizationId('user'));
     $this->assertEquals(array(), $tree->getUserOrganizationIds('user'));
     $this->assertEquals(array('bu1'), $tree->getUserSubordinateBusinessUnitIds('user', 'org1'));
     $this->assertEquals(array(), $tree->getBusinessUnitsIdByUserOrganizations('user'));
     $tree->addUserBusinessUnit('user', 'org2', 'bu2');
     $tree->addUserOrganization('user', 'org2');
     $this->assertEquals(array('bu1', 'bu2'), $tree->getUserBusinessUnitIds('user'));
     $this->assertEquals(array('bu2'), $tree->getUserBusinessUnitIds('user', 'org2'));
     $this->assertNull($tree->getUserOrganizationId('user'));
     $this->assertEquals(array('org2'), $tree->getUserOrganizationIds('user'));
     $this->assertEquals(array('bu2'), $tree->getUserSubordinateBusinessUnitIds('user', 'org2'));
     $this->assertEquals(array('bu1', 'bu2'), $tree->getUserSubordinateBusinessUnitIds('user'));
     $this->assertEquals(array('bu2'), $tree->getBusinessUnitsIdByUserOrganizations('user', 'org2'));
     $tree->addUserBusinessUnit('user', 'org3', 'bu3');
     $tree->addUserOrganization('user', 'org3');
     $this->assertEquals(array('bu1', 'bu2', 'bu3'), $tree->getUserBusinessUnitIds('user'));
     $this->assertNull($tree->getUserOrganizationId('user'));
     $this->assertEquals(array('org2', 'org3'), $tree->getUserOrganizationIds('user'));
     $this->assertEquals(array('bu1', 'bu2', 'bu3'), $tree->getUserSubordinateBusinessUnitIds('user'));
     $this->assertEquals(array('bu3'), $tree->getUserSubordinateBusinessUnitIds('user', 'org3'));
     $this->assertEquals(array('bu2', 'bu3'), $tree->getBusinessUnitsIdByUserOrganizations('user'));
 }
Пример #2
0
 public function testAddUserBusinessUnitBelongToDifferentOrganizations()
 {
     $tree = new OwnerTree();
     $tree->addBasicEntity('user', null);
     $tree->addLocalEntity('bu1', null);
     $this->assertNull($tree->getBusinessUnitOrganizationId('bu1'));
     $tree->addLocalEntity('bu2', 'org2');
     $this->assertEquals('org2', $tree->getBusinessUnitOrganizationId('bu2'));
     $tree->addLocalEntity('bu3', 'org3');
     $this->assertEquals('org3', $tree->getBusinessUnitOrganizationId('bu3'));
     $tree->addLocalEntityToBasic('user', null, null);
     $this->assertEquals([], $tree->getUserBusinessUnitIds('user'));
     $this->assertNull($tree->getUserOrganizationId('user'));
     $this->assertEquals([], $tree->getUserOrganizationIds('user'));
     $this->assertEquals([], $tree->getUserSubordinateBusinessUnitIds('user', 'org1'));
     $this->assertEquals([], $tree->getBusinessUnitsIdByUserOrganizations('user'));
     $tree->addLocalEntityToBasic('user', 'bu1', 'org1');
     $this->assertEquals(['bu1'], $tree->getUserBusinessUnitIds('user'));
     $this->assertNull($tree->getUserOrganizationId('user'));
     $this->assertEquals([], $tree->getUserOrganizationIds('user'));
     $this->assertEquals(['bu1'], $tree->getUserSubordinateBusinessUnitIds('user', 'org1'));
     $this->assertEquals([], $tree->getBusinessUnitsIdByUserOrganizations('user'));
     $tree->addLocalEntityToBasic('user', 'bu2', 'org2');
     $tree->addGlobalEntity('user', 'org2');
     $this->assertEquals(['bu1', 'bu2'], $tree->getUserBusinessUnitIds('user'));
     $this->assertEquals(['bu2'], $tree->getUserBusinessUnitIds('user', 'org2'));
     $this->assertNull($tree->getUserOrganizationId('user'));
     $this->assertEquals(['org2'], $tree->getUserOrganizationIds('user'));
     $this->assertEquals(['bu2'], $tree->getUserSubordinateBusinessUnitIds('user', 'org2'));
     $this->assertEquals(['bu1', 'bu2'], $tree->getUserSubordinateBusinessUnitIds('user'));
     $this->assertEquals(['bu2'], $tree->getBusinessUnitsIdByUserOrganizations('user'));
     $tree->addLocalEntityToBasic('user', 'bu3', 'org3');
     $tree->addGlobalEntity('user', 'org3');
     $this->assertEquals(['bu1', 'bu2', 'bu3'], $tree->getUserBusinessUnitIds('user'));
     $this->assertNull($tree->getUserOrganizationId('user'));
     $this->assertEquals(['org2', 'org3'], $tree->getUserOrganizationIds('user'));
     $this->assertEquals(['bu1', 'bu2', 'bu3'], $tree->getUserSubordinateBusinessUnitIds('user'));
     $this->assertEquals(['bu3'], $tree->getUserSubordinateBusinessUnitIds('user', 'org3'));
     $this->assertEquals(['bu2', 'bu3'], $tree->getBusinessUnitsIdByUserOrganizations('user'));
 }