13 require_once
'PU_testcase_dcp_commonfamily.php';
26 "PU_data_dcp_role_family.ods"
32 public function testRoleByGroup(array $addTo, array $expectedRoles)
35 $u->login =
"tst_jd1";
36 $u->password_new =
'a';
38 $this->assertEmpty(
$err,
"cannot create user");
40 $this->assertTrue($du->isAlive() ,
"cannot create user document");
42 foreach ($addTo as $aGroupName) {
47 $err = $dg->insertDocument($du->id);
48 $this->assertEmpty(
$err,
"cannot add user to $aGroupName");
50 $u->setLoginName(
"tst_jd1");
51 $uRoles = $u->getAllRoles();
52 $uRoleLogins = array();
53 foreach ($uRoles as $aRole) {
54 $uRoleLogins[] = $aRole[
"login"];
57 foreach ($expectedRoles as $roleLogin) {
58 $this->assertTrue(in_array($roleLogin, $uRoleLogins) , sprintf(
"role %s must be present", $roleLogin));
60 foreach ($uRoleLogins as $roleLogin) {
61 $this->assertTrue(in_array($roleLogin, $expectedRoles) , sprintf(
"role %s must not be present", $roleLogin));
72 $this->assertTrue($u->isAffected() ,
"cannot find $login user");
73 $uRoleIds = $u->getRoles();
74 simpleQuery(
self::$dbaccess, sprintf(
"select login from users where id in (%s)", implode(
',', $uRoleIds)) , $uRoleLogins,
true);
76 foreach ($expectedRoles as $roleLogin) {
77 $this->assertTrue(in_array($roleLogin, $uRoleLogins) , sprintf(
"role %s must be present", $roleLogin));
79 foreach ($uRoleLogins as $roleLogin) {
80 $this->assertTrue(in_array($roleLogin, $expectedRoles) , sprintf(
"role %s must not be present", $roleLogin));
87 public function testRoleMail($roleLogin, $expectRawMail, $expectCompleteMail)
90 $r->setLoginName($roleLogin);
91 $this->assertTrue(
$r->isAffected() ,
"cannot find $roleLogin role");
93 $rawMail =
$r->getMail(
true);
94 $completeMail =
$r->getMail(
false);
95 $this->assertEquals($expectRawMail, $rawMail,
"role raw mail test");
96 $this->assertEquals($expectCompleteMail, $completeMail,
"role complete mail test");
101 $this->assertTrue($dr->isAlive() ,
"cannot find $roleLogin document role");
103 $rawMail = $dr->getMail(
true);
104 $completeMail = $dr->getMail(
false);
105 $this->assertEquals($expectRawMail, $rawMail,
"document role raw mail test");
106 $this->assertEquals($expectCompleteMail, $completeMail,
"document role complete mail test");
115 $this->assertTrue(
$d->isAlive() ,
"document $docid not found");
117 foreach ($expectedAccesses as $aName => $aAccess) {
118 $err =
$d->control($aName);
119 $this->assertEquals($aAccess, (
$err ==
"") ,
"error in access $aName : $err");
127 "docName" =>
"TST_BASERED1",
136 "docName" =>
"TST_BASERED1",
146 "docName" =>
"TST_BASERED2",
155 "docName" =>
"TST_BASERED2",
164 "docName" =>
"TST_BASEBLUE1",
173 "docName" =>
"TST_BASEBLUE1",
183 "docName" =>
"TST_BASEBLUE2",
192 "docName" =>
"TST_BASEBLUE2",
201 "docName" =>
"TST_BASEYELLOW1",
210 "docName" =>
"TST_BASEYELLOW1",
220 "docName" =>
"TST_BASEYELLOW2",
229 "docName" =>
"TST_BASEYELLOW2",
238 "docName" =>
"TST_BASEYELLOW2",
239 "login" =>
"uryellow",
247 "docName" =>
"TST_BASEYELLOW2",
248 "login" =>
"urgreen",
256 "docName" =>
"TST_BASEYELLOW2",
257 "login" =>
"uggreen",
266 "docName" =>
"TST_BASEGREEN",
275 "docName" =>
"TST_BASEGREEN",
284 "docName" =>
"TST_BASEGREEN",
285 "login" =>
"uryellow",
293 "docName" =>
"TST_BASEGREEN",
294 "login" =>
"urgreen",
302 "docName" =>
"TST_BASEGREEN",
303 "login" =>
"uggreen",
318 "rawMail" =>
"blue@anakeen.com, green@anakeen.com, green@group.org, green@role.org",
319 "completeMail" =>
'"John Bleu" <blue@anakeen.com>, "Jane Vert" <green@anakeen.com>, "John Vert" <green@group.org>, "John Blue-Yellow" <green@role.org>'
323 "rawMail" =>
"blue@anakeen.com",
324 "completeMail" =>
'"John Bleu" <blue@anakeen.com>'
327 "login" =>
"ryellow",
328 "rawMail" =>
"green@anakeen.com, green@group.org, green@role.org, yellow@role.org",
329 "completeMail" =>
'"Jane Vert" <green@anakeen.com>, "John Vert" <green@group.org>, "John Blue-Yellow" <green@role.org>, "Jane Jaune" <yellow@role.org>'
339 "expectRoles" => array(
345 "expectRoles" => array(
360 "expectRoles" => array(
368 "expectRoles" => array(
377 "expectRoles" => array(
386 "expectRoles" => array(
396 "expectRoles" => array(
406 "expectRoles" => array(
418 "expectRoles" => array(
426 "expectRoles" => array()
testDirectRole($login, array $expectedRoles)
static getCommonImportFile()
testAccessByRole($docid, $login, array $expectedAccesses)
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
if($file) if($subject==""&&$file) if($subject=="") $err