13 require_once
'PU_testcase_dcp_commonfamily.php';
26 return "PU_data_dcp_fullsearchfamily1.ods";
33 public function testGeneralFilter(
$filter, array $expectedDocName)
42 $s->setObjectReturn(
true);
46 $this->assertEmpty(
$err,
"search error : $err");
47 $dl =
$s->getDocumentList();
49 if (count($expectedDocName) !=
$s->count()) {
50 $this->assertEquals(count($expectedDocName) ,
$s->count() ,
"not correct count " . $this->getFilterResult($dl) . print_r(
$s->getSearchInfo() ,
true));
57 $this->assertEquals($expectedDocName[$index],
$doc->name, print_r(
$s->getSearchInfo() ,
true));
58 $this->assertEquals(
$doc->id,
$docid,
"document key is not correct");
66 public function testArrayGeneralFilter(
$filter, array $expectedDocName)
70 $s->setObjectReturn(
false);
74 $this->assertEmpty(
$err,
"search error : $err");
75 $dl =
$s->getDocumentList();
77 if (count($expectedDocName) !=
$s->count()) {
78 $this->assertEquals(count($expectedDocName) ,
$s->count() ,
"not correct count " . $this->getFilterResult($dl) . print_r(
$s->getSearchInfo() ,
true));
85 $this->assertEquals($expectedDocName[$index],
$doc[
"name"]);
86 $this->assertEquals(
$doc[
"id"],
$docid,
"document key is not correct");
93 public function testGeneralSortFilter(
$filter, $order, array $expectedDocName)
97 $s->setObjectReturn();
98 $s->setPertinenceOrder($order);
102 $this->assertEmpty(
$err,
"search error : $err");
103 $dl =
$s->getDocumentList();
105 if (count($expectedDocName) >
$s->count()) {
106 $this->assertLessThanOrEqual(count($expectedDocName) ,
$s->count() ,
"not correct count " . $this->getFilterResult($dl) . print_r(
$s->getSearchInfo() ,
true));
113 foreach ($dl as
$doc) {
114 if (!empty($expectedDocName[$index])) {
115 $this->assertEquals($expectedDocName[$index], $doc->name, print_r(
$s->getSearchInfo() ,
true));
123 public function testSpellGeneralFilter(
$filter, array $expectedDocName)
127 $s->setObjectReturn();
131 $this->assertEmpty(
$err,
"search error : $err");
133 $dl =
$s->getDocumentList();
134 if (count($expectedDocName) !=
$s->count()) {
135 $this->assertEquals(count($expectedDocName) ,
$s->count() ,
"not correct count " . $this->getFilterResult($dl));
138 $this->assertEquals(count($expectedDocName) ,
$s->count() ,
"not correct count " . $this->getFilterResult($dl));
143 foreach ($dl as $doc) {
144 $this->assertEquals($expectedDocName[$index], $doc->name);
158 $s->setObjectReturn();
162 $code = $e->getDcpCode();
164 $this->assertEquals($expectedCore, $code,
"search error must not be empty");
177 $this->assertTrue(
$dir->isAlive() , sprintf(
"Could not get search with id '%s'.", $dirId));
180 $search->setObjectReturn();
181 $search->useCollection($dirId);
182 $search->addFilter(
"name ~ '^TST_USEFOR'");
186 while ($doc = $search->getNextDoc()) {
190 if (count($existsNameList) > 0) {
191 foreach ($existsNameList as $name) {
192 $this->assertTrue(in_array($name, $res) , sprintf(
"Missing document with name '%s' in search with collection '%s': returned documents name = {%s}", $name,
$dir->name, join(
', ', $res)));
196 if (count($notExistsNameList) > 0) {
197 foreach ($notExistsNameList as $name) {
198 $this->assertTrue(!in_array($name, $res) , sprintf(
"Found unexpected document with name '%s' in search with collection '%s': returned documents name = {%s}", $name,
$dir->name, join(
', ', $res)));
219 '(coucou) OR " (DF"Oio)',
229 "TST_USEFOR_SYSTEM_SEARCH_NO",
242 "TST_USEFOR_SYSTEM_SEARCH_YES",
254 "TST_USEFOR_SYSTEM_SEARCH_EMPTY",
266 "TST_USEFOR_SYSTEM_DSEARCH_NO",
279 "TST_USEFOR_SYSTEM_DSEARCH_YES",
291 "TST_USEFOR_SYSTEM_DSEARCH_EMPTY",
321 while ($doc =
$search->getNextDoc()) {
325 if (count($existsNameList) > 0) {
326 foreach ($existsNameList as $name) {
327 $this->assertTrue(in_array($name, $res) , sprintf(
"Document '%s' should be returned by search for '%s' on family '%s': returned documents name = {%s}", $name,
$keyword, $fam, join(
', ', $res)));
331 if (count($notExistsNameList) > 0) {
332 foreach ($notExistsNameList as $name) {
333 $this->assertTrue(!in_array($name, $res) , sprintf(
"Document '%s' should NOT be returned by search for '%s' on family '%s': returned documents name = {%s}", $name,
$keyword, $fam, join(
', ', $res)));
342 "TST_OPT_SEARCHCRITERIA",
345 "TST_OPT_SEARCHCRITERIA_DEFAULT",
346 "TST_OPT_SEARCHCRITERIA_VISIBLE",
347 "TST_OPT_SEARCHCRITERIA_PROTECTED"
350 "TST_OPT_SEARCHCRITERIA_HIDDEN"
354 "TST_OPT_SEARCHCRITERIA",
358 "TST_OPT_SEARCHCRITERIA_DEFAULT",
359 "TST_OPT_SEARCHCRITERIA_VISIBLE",
360 "TST_OPT_SEARCHCRITERIA_HIDDEN",
361 "TST_OPT_SEARCHCRITERIA_PROTECTED"
379 if (is_array($properties)) {
380 foreach ($properties as $prop =>
$value) {
384 if (is_array($methods)) {
385 foreach ($methods as
$method) {
389 if (is_array($filters)) {
390 foreach ($filters as
$filter) {
395 if (is_array($filter)) {
402 call_user_func_array($call,
$args);
407 $this->assertTrue(($count == $expectedCount) , sprintf(
"onlyCount() returned '%s' while expecting '%s' (query = [%s]).", $count, $expectedCount,
$search->getOriginalQuery()));
444 "title <> 'Just to add some SQL conditions in the query...'",
445 "title <> '... blah blah blah'"
458 "title <> 'Just to add some SQL conditions in the query...'",
459 "title <> '... blah blah blah'"
472 "a_title <> 'Just to add some SQL conditions in the query...'",
473 "a_title <> '... blah blah blah'"
486 "a_title <> 'Just to add some SQL conditions in the query...'",
487 "a_title <> '... blah blah blah'"
501 $search->setObjectReturn(
true);
502 $search->setOrder($orderby, $orderbyLabel);
506 $this->assertTrue($count == $expectedCount, sprintf(
"search with setOrder(%s, %s) returned '%s' elements while expecting '%s'.", var_export($orderby,
true) , var_export($orderbyLabel,
true) , $count, $expectedCount));
509 while ($doc =
$search->getNextDoc()) {
510 $titles[] = $doc->title;
513 $s1 = join(
', ', $titles);
514 $s2 = join(
', ', $expectedTitles);
515 $this->assertTrue($s1 == $s2, sprintf(
"Expected titles not found: titles = [%s] / expected titles = [%s] / sql = [%s]", $s1, $s2,
$search->getOriginalQuery()));
641 $search->useCollection($collectionId);
642 $search->setObjectReturn(
true);
643 $search->setOrder($orderby, $orderbyLabel);
647 $this->assertTrue($count == $expectedCount, sprintf(
"search with setOrder(%s, %s) returned '%s' elements while expecting '%s'.", var_export($orderby,
true) , var_export($orderbyLabel,
true) , $count, $expectedCount));
650 while ($doc =
$search->getNextDoc()) {
651 $titles[] = $doc->title;
654 $s1 = join(
', ', $titles);
655 $s2 = join(
', ', $expectedTitles);
656 $this->assertTrue($s1 == $s2, sprintf(
"Expected titles not found: titles = [%s] / expected titles = [%s] / sql = [%s]", $s1, $s2,
$search->getOriginalQuery()));
663 'TST_ORDERBY_LABEL_COLLECTION_1',
674 'TST_ORDERBY_LABEL_COLLECTION_1',
685 'TST_ORDERBY_LABEL_COLLECTION_1',
696 'TST_ORDERBY_LABEL_COLLECTION_1',
707 'TST_ORDERBY_LABEL_COLLECTION_1',
718 'TST_ORDERBY_LABEL_COLLECTION_1',
729 'TST_ORDERBY_LABEL_COLLECTION_1',
740 'TST_ORDERBY_LABEL_COLLECTION_1',
751 'TST_ORDERBY_LABEL_COLLECTION_1',
762 'TST_ORDERBY_LABEL_COLLECTION_1',
781 foreach ($dl as $doc) {
782 if (is_array($doc)) {
784 $names[] = $doc[
"name"];
786 $names[] = $doc->name;
789 return implode(
",", $names);
948 'le avec "téléphone"',
995 "téléphones portables",
1001 'téléphones "portables"',
1005 'téléphones "portable"',
1011 "téléphones AND portables",
1017 '"téléphones" AND portables',
1021 '"téléphone" AND portables',
1033 "(téléphones) (fixes)",
1039 "(téléphones) fixes",
1152 '*fushia\)* OR *mineux\)*',
1173 "portàble OR fixe OR cheval",
1182 "téléphone OR (jument AND rouge)",
1190 "téléphone OR (rouge jument)",
1209 '"rouges" OR "cheval"',
1216 '"rouges" OR "cheval" OR animaux',
1225 '("rouges" OR "cheval") AND animaux',
1280 "comme l'éclair jaunes",
1379 '2012-01-15 chiens',
1385 '2012 15 01 chiens',
1397 '06 04 2013 john doe',
1441 'march july 2016 2017',
1447 'mars juillet 2016 2017',
1460 'Chien rouge en été et printemps',
1481 'A2 canin C1 deuxième',
1489 'A2 canin C1 deuxième A4 canasson',
1496 'C1 A2 A3 canin C1 deuxième A4 canasson',
1563 '"rouge" OR "cheval"',
1573 '"rouge" OR chevaux',
1582 "comme l'éclair jaune",
1589 "comme l'éclair' jaune",
1596 "comme l'éclair jaunes",
1603 "comme les éclairs jaunes",
1610 "comme l'éclair jaun*",
1617 '"rouge" OR chevaux OR télé*',
if(substr($wsh, 0, 1)!= '/') $args
dataOptionSearchCriteria()
static getCommonImportFile()
testOptionSearchCriteria($fam, $keyword, $existsNameList, $notExistsNameList)
dataSearchDocSetOrderWithCollection()
testUseforSystemSearchDocWithCollection($dirId, $existsNameList, $notExistsNameList)
new_Doc($dbaccess, $id= '', $latest=false)
testErrorGeneralFilter($filter, $expectedCore)
dataUseforSystemSearchDocWithCollection()
testSearchDocOnlyCount($fam, $properties, $methods, $filters, $expectedCount)
testSearchDocSetOrderWithCollection($collectionId, $orderby, $orderbyLabel, $expectedCount, $expectedTitles=array())
if($file) if($subject==""&&$file) if($subject=="") $err
testSearchDocSetOrder($fam, $orderby, $orderbyLabel, $expectedCount, $expectedTitles=array())