Example #1
0
 public function testAddUser()
 {
     /* check auth methods */
     $this->object->addUser("fred", "ted");
     MongoAuth::getHash("fred", "ted");
     $a2 = new MongoAdmin();
     $this->assertTrue($a2->connected);
     $a2->login("fred", "ted");
     $this->assertTrue($a2->loggedIn, json_encode($a2));
     $x = $this->object->changePassword("fred", "ted", "foobar");
     $this->assertEquals(1, $x['ok'], json_encode($x));
     $a2 = new MongoAdmin();
     $a2->login("fred", "ted");
     $this->assertFalse($a2->loggedIn);
     $a2 = new MongoAdmin();
     $a2->login("fred", "foobar");
     $this->assertTrue($a2->loggedIn);
     $this->object->deleteUser("fred");
     $a2 = new MongoAdmin();
     $a2->login("fred", "foobar");
     $this->assertFalse($a2->loggedIn);
 }