Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_user.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_document.php';
13 
15 {
16  /**
17  * @dataProvider dataUserCreate
18  * @param string $login
19  * @param string $password
20  */
21  public function testDeleteUser($login, $password)
22  {
23  $user = $this->testCreateUser($login, $password);
24  $err = $user->Delete();
25  $this->assertEmpty($err, sprintf("cannot delete iuser %s", $err));
26  }
27  /**
28  * @dataProvider dataUserCreate
29  * @param string $login login of user
30  * @param string $password password of user
31  * @return \_IUSER|\Doc
32  */
33  public function testCreateUser($login, $password)
34  {
35  /**
36  * @var \_IUSER $doc
37  */
38  $doc = createDoc(self::$dbaccess, "IUSER");
39  $this->assertTrue(is_object($doc) , "cannot create user");
40  $err = $doc->setValue("us_login", $login);
41  $err.= $doc->setValue("us_passwd1", $password);
42  $err.= $doc->setValue("us_passwd2", $password);
43  $this->assertEmpty($err, sprintf("cannot set iuser %s", $err));
44 
45  $err = $doc->store();
46  $this->assertEmpty($err, sprintf("cannot store iuser %s", $err));
47 
48  $u = new \Account();
49  $this->assertTrue($u->setLoginName($login) , "system user not found");
50  $this->assertEquals($login, $u->login);
51  $this->assertEquals($doc->id, $u->fid, "mismatch document iuser reference");
52  $this->assertEquals($doc->getRawValue("us_whatid") , $u->id, "mismatch system iuser reference");
53  return $doc;
54  }
55  /**
56  * @dataProvider dataNotUserCreate
57  * @param string $login login of user
58  * @param string $password password of user
59  */
60  public function testNotCreateUser($login, $password)
61  {
62 
63  $doc = createDoc(self::$dbaccess, "IUSER");
64  $this->assertTrue(is_object($doc) , "cannot create user");
65  $err = $doc->setValue("us_login", $login);
66  $err.= $doc->setValue("us_passwd1", $password);
67  $err.= $doc->setValue("us_passwd2", $password);
68  $this->assertEmpty($err, sprintf("cannot set iuser %s", $err));
69 
70  $err = $doc->store();
71  $this->assertNotEmpty($err, sprintf("must be impossible to store iuser"));
72 
73  $u = new \Account();
74  $this->assertTrue($u->setLoginName($login) , "system user not found");
75  $this->assertEquals($login, $u->login);
76  }
77 
78  public function dataUserCreate()
79  {
80  return array(
81  array(
82  "joe",
83  "secret"
84  ) ,
85  array(
86  "joe2",
87  "secret"
88  )
89  );
90  }
91 
92  public function dataNotUserCreate()
93  {
94  return array(
95  array(
96  "admin",
97  "secret"
98  ) ,
99  array(
100  "anonymous",
101  "secret"
102  )
103  );
104  }
105 }
106 ?>
testNotCreateUser($login, $password)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
$login
Definition: dav.php:40
testDeleteUser($login, $password)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen