示例#1
0
 /**
  * Test for data_connector::deleteUser().
  */
 public function test_delete_user()
 {
     $dc = new data_connector();
     $consumer = new ToolConsumer(null, $dc);
     $consumer->name = 'TestName';
     $consumer->setKey('TestKey');
     $consumer->secret = 'TestSecret';
     $consumer->save();
     $resourcelink = ResourceLink::fromConsumer($consumer, 'testresourcelinkid');
     $resourcelink->save();
     $user = User::fromResourceLink($resourcelink, '');
     $user->ltiResultSourcedId = 'testLtiResultSourcedId';
     $user->firstname = 'First';
     $user->lastname = 'Last';
     $user->fullname = 'Full name';
     $user->email = '*****@*****.**';
     $user->roles = ['a', 'b'];
     $user->groups = ['1', '2'];
     $user->save();
     // Delete user.
     $this->assertTrue($dc->deleteUser($user));
     // User record should have been deleted from the DB.
     $this->assertFalse($dc->loadUser($user));
     // User object should have been initialised().
     $this->assertEmpty($user->firstname);
     $this->assertEmpty($user->lastname);
     $this->assertEmpty($user->fullname);
     $this->assertEmpty($user->email);
     $this->assertEmpty($user->roles);
     $this->assertEmpty($user->groups);
     $this->assertNull($user->ltiResultSourcedId);
     $this->assertNull($user->created);
     $this->assertNull($user->updated);
 }