Ejemplo n.º 1
0
 public function testLookupUserNames()
 {
     $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->lookupUserNames(array()));
     $expect = $this->localUsers;
     $expect['UTDoesNotExist'] = 'X';
     ksort($expect);
     $expect2 = $expect;
     $expect2['UTLocalIdLookup4'] = 'X';
     $arg = array_fill_keys(array_keys($expect), 'X');
     $this->assertSame($expect2, $lookup->lookupUserNames($arg));
     $this->assertSame($expect, $lookup->lookupUserNames($arg, CentralIdLookup::AUDIENCE_RAW));
     $this->assertSame($expect, $lookup->lookupUserNames($arg, $user1));
     $this->assertSame($expect2, $lookup->lookupUserNames($arg, $user2));
 }
Ejemplo n.º 2
0
 public function testLookupUserNames()
 {
     $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->lookupUserNames([]));
     $expect = [];
     foreach ($this->localUsers as $localUser) {
         $expect[$localUser->getName()] = $localUser->getId();
     }
     $expect['UTDoesNotExist'] = 'X';
     ksort($expect);
     $expect2 = $expect;
     $expect2[$this->localUsers[3]->getName()] = 'X';
     $arg = array_fill_keys(array_keys($expect), 'X');
     $this->assertSame($expect2, $lookup->lookupUserNames($arg));
     $this->assertSame($expect, $lookup->lookupUserNames($arg, CentralIdLookup::AUDIENCE_RAW));
     $this->assertSame($expect, $lookup->lookupUserNames($arg, $user1));
     $this->assertSame($expect2, $lookup->lookupUserNames($arg, $user2));
 }