Example #1
0
 /**
  * tests clean up
  */
 public function tearDown()
 {
     if (!is_null($this->userService)) {
         $this->userService->removeUser($this->testUser);
     }
     if (tao_models_classes_UserService::singleton()->isASessionOpened()) {
         tao_models_classes_UserService::singleton()->logout();
     }
     if (isset($_SESSION)) {
         //session not started in testsuite
         //session_destroy();
     }
 }
Example #2
0
 /**
  * Clearing up ( in case if delete test was not executed )
  */
 public function __destruct()
 {
     if ($this->testUser) {
         $this->userService->removeUser($this->testUser);
     }
     if ($this->testUserUtf8) {
         $this->userService->removeUser($this->testUserUtf8);
     }
 }
 /**
  * Test user removing
  * @see tao_models_classes_UserService::removeUser
  */
 public function testDelete()
 {
     $this->testUser = $this->getUserByLogin($this->testUserData[PROPERTY_USER_LOGIN]);
     $this->assertIsA($this->testUser, 'core_kernel_classes_Resource');
     $this->assertTrue($this->userService->removeUser($this->testUser));
     $this->assertTrue($this->userService->loginAvailable($this->testUserData[PROPERTY_USER_LOGIN]));
     $this->testUserUtf8 = $this->getUserByLogin($this->testUserUtf8Data[PROPERTY_USER_LOGIN]);
     $this->assertIsA($this->testUserUtf8, 'core_kernel_classes_Resource');
     $this->assertTrue($this->userService->removeUser($this->testUserUtf8));
     $this->assertTrue($this->userService->loginAvailable($this->testUserUtf8Data[PROPERTY_USER_LOGIN]));
 }
Example #4
0
 /**
  * Remove a user
  * The request must contains the user's login to remove
  * @return void
  */
 public function delete()
 {
     $deleted = false;
     $message = __('An error occured during user deletion');
     if (helpers_PlatformInstance::isDemo()) {
         $message = __('User deletion not permited on a demo instance');
     } elseif ($this->hasRequestParameter('uri')) {
         $user = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
         $this->checkUser($user->getUri());
         if ($this->userService->removeUser($user)) {
             $deleted = true;
             $message = __('User deleted successfully');
         }
     }
     $this->returnJson(array('deleted' => $deleted, 'message' => $message));
 }