public function testLookupCentralIds() { $lookup = new LocalIdLookup(); $user1 = User::newFromName('UTLocalIdLookup1'); $user2 = User::newFromName('UTLocalIdLookup2'); $this->assertTrue($user1->isAllowed('hideuser'), 'sanity check'); $this->assertFalse($user2->isAllowed('hideuser'), 'sanity check'); $this->assertSame(array(), $lookup->lookupCentralIds(array())); $expect = array_flip($this->localUsers); $expect[123] = 'X'; ksort($expect); $expect2 = $expect; $expect2[$this->localUsers['UTLocalIdLookup4']] = ''; $arg = array_fill_keys(array_keys($expect), 'X'); $this->assertSame($expect2, $lookup->lookupCentralIds($arg)); $this->assertSame($expect, $lookup->lookupCentralIds($arg, CentralIdLookup::AUDIENCE_RAW)); $this->assertSame($expect, $lookup->lookupCentralIds($arg, $user1)); $this->assertSame($expect2, $lookup->lookupCentralIds($arg, $user2)); }
public function testLookupCentralIds() { $lookup = new LocalIdLookup(); $user1 = $this->getLookupUser(); $user2 = User::newFromName('UTLocalIdLookup2'); $this->assertTrue($user1->isAllowed('hideuser'), 'sanity check'); $this->assertFalse($user2->isAllowed('hideuser'), 'sanity check'); $this->assertSame([], $lookup->lookupCentralIds([])); $expect = []; foreach ($this->localUsers as $localUser) { $expect[$localUser->getId()] = $localUser->getName(); } $expect[12345] = 'X'; ksort($expect); $expect2 = $expect; $expect2[$this->localUsers[3]->getId()] = ''; $arg = array_fill_keys(array_keys($expect), 'X'); $this->assertSame($expect2, $lookup->lookupCentralIds($arg)); $this->assertSame($expect, $lookup->lookupCentralIds($arg, CentralIdLookup::AUDIENCE_RAW)); $this->assertSame($expect, $lookup->lookupCentralIds($arg, $user1)); $this->assertSame($expect2, $lookup->lookupCentralIds($arg, $user2)); }