13 require_once
'PU_testcase_dcp_commonfamily.php';
26 "PU_data_dcp_searchaccount.ods"
32 public function testSearchByRole($roleFilter, $groupFilter, array $expectedAccounts)
34 $s = new \SearchAccount();
35 if ($roleFilter)
$s->addRoleFilter($roleFilter);
36 if ($groupFilter)
$s->addGroupFilter($groupFilter);
37 $s->setReturnType($s::returnAccount);
43 $expectedAccounts = array_map(
"mb_strtolower", $expectedAccounts);
44 $loginFounds = array();
46 $lLogin = $this->getAccounlLogin($al);
52 $this->assertTrue(in_array(
$login, $expectedAccounts) , sprintf(
"login <%s> must not be present : %s",
$login, $lLogin));
56 foreach ($expectedAccounts as $expectLogin) {
57 $this->assertTrue(in_array($expectLogin, $loginFounds) , sprintf(
"login <%s> must be present", $expectLogin));
67 foreach ($al as $account) {
68 $logins[] = $account->login;
70 return implode(
',', $logins);
75 public function testSearchByRoleDocument($roleFilter, $groupFilter, array $expectedAccounts)
77 $s = new \SearchAccount();
78 if ($roleFilter)
$s->addRoleFilter($roleFilter);
79 if ($groupFilter)
$s->addGroupFilter($groupFilter);
80 $s->setReturnType($s::returnDocument);
86 $expectedAccounts = array_map(
"mb_strtolower", $expectedAccounts);
87 $loginFounds = array();
91 foreach ($al as
$doc) {
93 if ($doc->getAttribute(
"us_login"))
$login = $doc->getRawValue(
"us_login");
94 elseif ($doc->getAttribute(
"role_login"))
$login = $doc->getRawValue(
"role_login");
95 $this->assertTrue(in_array(
$login, $expectedAccounts) , sprintf(
"login <%s> #%s must not be present",
$login, $doc->id));
99 foreach ($expectedAccounts as $expectLogin) {
100 $this->assertTrue(in_array($expectLogin, $loginFounds) , sprintf(
"login <%s> must be present", $expectLogin));
106 public function testCountSearchByRole(
$slice,
$start, $order, $roleFilter, array $expectedAccounts)
108 $s = new \SearchAccount();
109 $s->addRoleFilter($roleFilter);
112 $s->setOrder($order);
113 $s->setReturnType($s::returnAccount);
119 $expectedAccounts = array_map(
"mb_strtolower", $expectedAccounts);
124 foreach ($al as $account) {
126 $this->assertEquals($expectedAccounts[$k],
$login, sprintf(
"%s login must not be present",
$login));
133 public function testFilterSearch(
$filter, $filterArg, $accountType, array $expectedAccounts)
135 $s = new \SearchAccount();
137 if ($accountType)
$s->setTypeFilter($accountType);
138 $s->setOrder(
"login");
139 $s->setReturnType($s::returnAccount);
145 $expectedAccounts = array_map(
"mb_strtolower", $expectedAccounts);
146 $ll = $this->getAccounlLogin($al);
151 foreach ($al as $account) {
153 $this->assertEquals($expectedAccounts[$k],
$login, sprintf(
"%s login must not be present : found %s",
$login, $ll));
156 $this->assertEquals(count($expectedAccounts) , count($al) , sprintf(
"not same count expected %d : %s", count($expectedAccounts) , $ll));
161 public function testFilterViewControl(
$login,
$filter, $filterArg, array $expectedAccounts)
164 $s = new \SearchAccount();
166 $s->setOrder(
"login");
167 $s->overrideViewControl(
false);
168 $s->setReturnType($s::returnAccount);
174 $expectedAccounts = array_map(
"mb_strtolower", $expectedAccounts);
175 $ll = $this->getAccounlLogin($al);
180 foreach ($al as $account) {
182 $this->assertEquals($expectedAccounts[$k],
$login, sprintf(
"%s login must not be present : found %s",
$login, $ll));
186 $this->assertEquals(count($expectedAccounts) , count($al) , sprintf(
"not same count expected %d : %s", count($expectedAccounts) , $ll));
199 public function testFilterByFamily($family,
$filter, $expectedCount)
201 $this->
sudo(
"tstlogina1");
202 $s = new \SearchAccount();
204 $s->setOrder(
"login");
205 $s->overrideViewControl(
false);
206 $s->setReturnType($s::returnAccount);
207 $s->filterFamily($family);
213 $ll = $this->getAccounlLogin($al);
215 $this->assertEquals($expectedCount, count($al) , sprintf(
"not same count expected %d : %s", $expectedCount, $ll));
221 public function testFilterByFamilyNoView($family,
$filter, $expectedCount)
223 $s = new \SearchAccount();
225 $s->setOrder(
"login");
226 $s->overrideViewControl(
true);
227 $s->setReturnType($s::returnAccount);
228 $s->filterFamily($family);
234 $ll = $this->getAccounlLogin($al);
236 $this->assertEquals($expectedCount, count($al) , sprintf(
"not same count expected %d : %s", $expectedCount, $ll));
243 "family" =>
"TST_uSER",
244 "filter" =>
" login ~ '^tstloginu'",
248 "family" =>
"TST_OTHERuSER",
249 "filter" =>
" login ~ '^tstloginu'",
258 "login" =>
"tstLoginA1",
259 "filter" =>
"login ~ '%s'",
269 "login" =>
"tstLoginA2",
270 "filter" =>
"login ~ '%s'",
280 "login" =>
"tstLoginU1",
281 "filter" =>
"login ~ '%s'",
291 "filter" =>
"login = lower('%s')",
292 "arg" =>
'tstLoginU1',
299 "filter" =>
"login ~ '^tst.*1$'",
309 "filter" =>
"login ~ '%s'",
317 "filter" =>
"login ~ '%s'",
325 "filter" =>
"login ~ '%s'",
334 "filter" =>
"login ~ '%s'",
345 "filter" =>
"login ~ '%s'",
382 "role" =>
"tstLoginR1",
394 "order" =>
"id desc",
395 "role" =>
"tstLoginR1",
408 "role" =>
"tstLoginR1",
418 "role" =>
"tstLoginR1",
431 "role" =>
"tstLoginR1",
443 "role" =>
"tstLoginR2",
454 "role" =>
"tstLoginR3",
464 "role" =>
"tstLoginR3 tstLoginR2",
476 "role" =>
"tstLoginR3 tstLoginR1 tstLoginR2",
490 "role" =>
"tstLoginR4",
502 "group" =>
"tstLoginG1",
512 "group" =>
"tstLoginG2",
522 "group" =>
"tstLoginG3",
531 "group" =>
"tstLoginG3 tstLoginG2 tstLoginG1",
543 "role" =>
"tstLoginR3",
544 "group" =>
"tstLoginG3",
static getCommonImportFile()
static getLoginFromDocName($name)
testDocName2Login($docName, $login)