Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_user_deactivate_account.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 namespace Dcp\Pu;
8 /**
9  * @author Anakeen
10  * @package Dcp\Pu
11  */
12 require_once 'PU_testcase_dcp_commonfamily.php';
13 
15 {
16  protected static function getCommonImportFile()
17  {
18  return array(
19  'PU_data_dcp_user_deactivate_account.ods'
20  );
21  }
22  /**
23  * @dataProvider dataUserDeactivateAccount
24  */
25  public function testExecuteUserDeactivateAccount($effectiveUserLogin, $targetUserId)
26  {
27  $this->sudo($effectiveUserLogin);
28  /**
29  * @var \_IUSER $user
30  */
31  $user = new_Doc(self::$dbaccess, $targetUserId, true);
32  $this->assertTrue($user->isAlive() , sprintf("Could not get user with id '%s'.", $targetUserId));
33  // the $effectiveUserLogin cannot do this operation
34  $err = $user->deactivateAccount();
35  $this->assertNotEmpty($err, "deactivate error must be detected");
36  $this->assertTrue($user->isAccountActive() , sprintf("User with id '%s' should be active.", $targetUserId));
37 
38  $this->exitSudo();
39  }
40  /**
41  * @dataProvider dataUserActivateAccount
42  */
43  public function testUserActivateAccount($effectiveUserLogin, $targetUserId)
44  {
45  $this->sudo($effectiveUserLogin);
46  /**
47  * @var \_IUSER $user
48  */
49  $user = new_Doc(self::$dbaccess, $targetUserId, true);
50  $this->assertTrue($user->isAlive() , sprintf("Could not get user with id '%s'.", $targetUserId));
51  // the $effectiveUserLogin cannot do this operation
52  $err = $user->activateAccount();
53 
54  $this->assertNotEmpty($err, "activate error must be detected");
55  $this->assertFalse($user->isAccountActive() , sprintf("User with id '%s' should not be active.", $targetUserId));
56 
57  $this->exitSudo();
58  }
59  /**
60  * @dataProvider dataDeActivateAccount
61  */
62  public function testDeActivateAccount($targetUserId)
63  {
64  /**
65  * @var \_IUSER $user
66  */
67  $user = new_Doc(self::$dbaccess, $targetUserId, true);
68  $this->assertTrue($user->isAlive() , sprintf("Could not get user with id '%s'.", $targetUserId));
69  $err = $user->deactivateAccount();
70 
71  $this->assertEmpty($err, "activate error detected : $err");
72  $this->assertFalse($user->isAccountActive() , sprintf("User with id '%s' should not be active.", $targetUserId));
73  $this->assertTrue($user->isAccountInActive() , sprintf("User with id '%s' should not be active.", $targetUserId));
74  $err = $user->activateAccount();
75 
76  $this->assertEmpty($err, "activate error detected : $err");
77  $this->assertTrue($user->isAccountActive() , sprintf("User with id '%s' should not be active.", $targetUserId));
78  $this->assertFalse($user->isAccountInActive() , sprintf("User with id '%s' should not be active.", $targetUserId));
79  }
80 
81  public function dataUserDeactivateAccount()
82  {
83  return array(
84  array(
85  "U_1",
86  "U_2"
87  )
88  );
89  }
90 
91  public function dataDeActivateAccount()
92  {
93  return array(
94  array(
95  "U_1"
96  ) ,
97  array(
98  "U_2"
99  )
100  );
101  }
102  public function dataUserActivateAccount()
103  {
104  return array(
105  array(
106  "U_1",
107  "U_3"
108  )
109  );
110  }
111 }
112 ?>
static sudo($login)
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen