Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_search.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package Dcp\Pu
5 */
6 
7 namespace Dcp\Pu;
8 
9 require_once 'PU_testcase_dcp_commonfamily.php';
10 
12 {
13 
14  public static function getCommonImportFile()
15  {
16  return array(
17  'PU_data_dcp_TestSearchGetOriginalQuery.ods'
18  );
19  }
20 
21  protected $famName = "TST_GETORIGINALQUERY1";
22  /**
23  * test basic search criteria
24  * @param string $criteria filter
25  * @param string $arg filter argument
26  * @param string $family family name or id
27  * @return void
28  * @dataProvider loginCriteria
29  */
30  public function testBasicSearch($criteria, $arg, $family)
31  {
32  $s = new \SearchDoc(self::$dbaccess, $family);
33  $s->addFilter($criteria, $arg);
34  $s->setObjectReturn(true);
35  $s->search();
36 
37  $err = $s->getError();
38  $this->assertEmpty($err, sprintf("Search error %s %s", $criteria, $arg));
39  }
40 
41  protected function createDataSearch()
42  {
43 
44  $fruits = array(
45  array(
46  "Pruneaux",
47  "Poire"
48  ) ,
49  array(
50  "Poire",
51  "Pomme"
52  ) ,
53  array(
54  "Mures",
55  "Cerise"
56  ) ,
57  array(
58  "Nèfle",
59  "Kiwi",
60  "Coing",
61  "Pomme-Banane"
62  ) ,
63  array(
64  "Banane"
65  ) ,
66  array(
67  "Melon",
68  "Raisin"
69  ) ,
70  array(
71  "Corme",
72  "__delete__"
73  ) ,
74  array(
75  "Corme",
76  "Orange",
77  "Prune",
78  "__delete__"
79  ) ,
80  );
81  $d1 = null;
82  foreach ($fruits as $socTitle) {
83  foreach ($socTitle as $k => $title) {
84 
85  if ($k === 0) {
86  $d1 = createDoc(self::$dbaccess, $this->famName, false);
87  $d1->setTitle($title);
88  $err = $d1->add();
89  $this->assertEmpty($err, "Cannot create data");
90  } else {
91 
92  if ($title === "__delete__") {
93 
94  $err = $d1->delete();
95  $this->assertEmpty($err, "Cannot delete data");
96  } else {
97  $d1->revise("Yo");
98  $d1->setTitle($title);
99  $err = $d1->modify();
100  $this->assertEmpty($err, "Cannot update data");
101  }
102  }
103  }
104  }
105 
106  return true;
107  }
108  /**
109  * test basic search criteria
110  * @param string $criteria filter
111  * @param string $arg filter argument
112  * @param string $family family name or id
113  * @param integer $count expected results count
114  * @return void
115  * @dataProvider countCriteria
116  */
117  public function testCountSearch($criteria, $arg, $family, $count)
118  {
119  $this->createDataSearch();
120  $s = new \SearchDoc(self::$dbaccess, $family);
121  if ($criteria) $s->addFilter($criteria, $arg);
122  $s->setObjectReturn(true);
123  $s->search();
124  $err = $s->getError();
125  $this->assertEmpty($err, sprintf("Search error %s %s", $criteria, $arg));
126 
127  $this->assertEquals($count, $s->count() , sprintf("Count must be %d (found %d) error %s %s", $count, $s->count() , $criteria, $arg));
128  }
129  /**
130  * test basic search criteria
131  * @param bool $latest
132  * @param bool $distinct
133  * @param string $trash
134  * @param string $criteria filter
135  * @param string $arg filter argument
136  * @param string $family family name or id
137  * @param array $expectTitles
138  * @dataProvider countAllRevisionCriteria
139  */
140  public function testCountRevisionSearch($latest, $distinct, $trash, $criteria, $arg, $family, array $expectTitles)
141  {
142  $this->createDataSearch();
143  $s = new \SearchDoc(self::$dbaccess, $family);
144  if ($criteria) $s->addFilter($criteria, $arg);
145  $s->setObjectReturn(true);
146  $s->latest = $latest;
147  $s->distinct = $distinct;
148  $s->trash = $trash;
149  $s->search();
150  $err = $s->getError();
151  $this->assertEmpty($err, sprintf("Search error %s %s", $criteria, $arg));
152 
153  $returnTitles = $this->getReturnTitles($s);
154  sort($returnTitles);
155  sort($expectTitles);
156  $this->assertEquals(count($expectTitles) , $s->count() , sprintf("Count error %s %s \nFound: %s %s", $criteria, $arg, implode(",", $returnTitles) , print_r($s->getSearchInfo() , true)));
157  $this->assertEquals($expectTitles, $returnTitles, sprintf("Not expected result %s %s \nFound : %s %s", $criteria, $arg, implode(", ", $returnTitles) , print_r($s->getSearchInfo() , true)));
158  }
159 
160  private function getReturnTitles(\SearchDoc $s)
161  {
162  $dl = $s->getDocumentList();
163  $titles = array();
164  foreach ($dl as $doc) {
165 
166  $titles[] = $doc->getTitle();
167  }
168 
169  return $titles;
170  }
171  /**
172  * test basic search criteria in array mode
173  * @param string $criteria filter
174  * @param string $arg filter argument
175  * @param string $family family name or id
176  * @param integer $count expected results count
177  * @return void
178  * @dataProvider countCriteria
179  */
180  public function testArrayCountSearch($criteria, $arg, $family, $count)
181  {
182  $this->createDataSearch();
183  $s = new \SearchDoc(self::$dbaccess, $family);
184  if ($criteria) $s->addFilter($criteria, $arg);
185  $s->setObjectReturn(false);
186  $s->search();
187 
188  $err = $s->getError();
189  $this->assertEmpty($err, sprintf("Search error %s %s", $criteria, $arg));
190 
191  $this->assertEquals($count, $s->count() , sprintf("Count must be %d (found %d) error %s %s", $count, $s->count() , $criteria, $arg));
192  }
193  /**
194  * test basic search criteria
195  * @param string $criteria filter
196  * @param string $arg filter argument
197  * @param string $family family name or id
198  * @param integer $count expected results count
199  * @return void
200  * @dataProvider countCriteria
201  * @depends testCountSearch
202  */
203  public function testOnlyCountSearch($criteria, $arg, $family, $count)
204  {
205  $this->createDataSearch();
206  $s = new \SearchDoc(self::$dbaccess, $family);
207  if ($criteria) $s->addFilter($criteria, $arg);
208  $s->setObjectReturn(true);
209  $c = - 2;
210  try {
211  $c = $s->onlyCount();
212  }
213  catch(\Dcp\Db\Exception $e) {
214  }
215 
216  $err = $s->getError();
217  $this->assertEmpty($err, sprintf("Search error %s %s", $criteria, $arg));
218 
219  $this->assertEquals($count, $s->count() , sprintf("Count must be %d (found %d) error %s %s", $count, $s->count() , $criteria, $arg));
220  $this->assertEquals($count, $c, sprintf("Return count must be %d (found %d) error %s %s", $count, $s->count() , $criteria, $arg));
221  }
222  /**
223  * test basic search criteria
224  * @param string $criteria filter
225  * @param string $arg filter argument
226  * @param string $family family name or id
227  * @param string $error expected error
228  * @return void
229  * @dataProvider countErrorCriteria
230  * @depends testCountSearch
231  */
232  public function testOnlyCountErrorSearch($criteria, $arg, $family, $error)
233  {
234  $this->createDataSearch();
235  $s = new \SearchDoc(self::$dbaccess, $family);
236  if ($criteria) $s->addFilter($criteria, $arg);
237  $s->setObjectReturn(true);
238  $c = null;
239  try {
240  $c = $s->onlyCount();
241  }
242  catch(\Dcp\Db\Exception $e) {
243  }
244  $err = $s->getError();
245  $this->assertContains($error, $err, sprintf("No good error %s", print_r($s->getSearchInfo() , true)));
246  $count = - 1;
247  $this->assertEquals($count, $s->count() , sprintf("Count must be %d (found %d) error %s %s", $count, $s->count() , $criteria, $arg));
248  $this->assertEquals($count, $c, sprintf("Return count must be %d (found %d) error %s %s", $count, $s->count() , $criteria, $arg));
249  }
250  /**
251  * test basic search criteria
252  * @param string $criteria filter
253  * @param string $arg filter argument
254  * @param string $family family name or id
255  * @param string $error expected error
256  * @return void
257  * @dataProvider countErrorCriteriaException
258  * @depends testCountSearch
259  */
260  public function testOnlyCountErrorSearchException($criteria, $arg, $family, $error)
261  {
262  $this->createDataSearch();
263  $s = new \SearchDoc(self::$dbaccess, $family);
264  if ($criteria) $s->addFilter($criteria, $arg);
265  $s->setObjectReturn(true);
266  $exceptionError = '';
267  try {
268  $s->onlyCount();
269  }
270  catch(\Dcp\Db\Exception $e) {
271  $exceptionError = $e->getMessage();
272  }
273  $getError = $s->getError();
274  $this->assertContains($error, $exceptionError, sprintf("Exception error '%s' does not contains '%s' (%s)", $exceptionError, $getError, print_r($s->getSearchInfo() , true)));
275  $this->assertContains($error, $getError, sprintf("getError() '%s' does not contains '%s' (%s)", $getError, $getError, print_r($s->getSearchInfo() , true)));
276  $count = - 1;
277  $this->assertEquals($count, $s->count() , sprintf("count() must be %d (found %d) error %s %s", $count, $s->count() , $criteria, $arg));
278  }
279  /**
280  * test only count user search
281  * @param array $data test specification
282  * @return void
283  * @dataProvider onlyCountWithNoViewControlCriteria
284  * @depends testCountSearch
285  */
287  {
288 
289  if (isset($data['import'])) {
290  $this->importDocument($data['import']);
291  }
292 
293  $this->assertTrue(isset($data['tests']) , sprintf("Missing 'tests'."));
294 
295  foreach ($data['tests'] as $i => & $test) {
296  if (isset($test['sudo'])) {
297  $this->sudo($test['sudo']);
298  }
299 
300  $fam = new_doc(self::$dbaccess, $test['search:family']);
301  $this->assertTrue($fam->isAlive() , sprintf("test#%s> Family '%s' not found.", $i, $test['search:family']));
302 
303  $s = new \SearchDoc(self::$dbaccess, $test['search:family']);
304  $s->setObjectReturn();
305  $count = - 2;
306  if (isset($test['search:noviewcontrol']) && $test['search:noviewcontrol']) {
307  $s->overrideViewControl();
308  }
309  try {
310  $count = $s->onlyCount();
311  }
312  catch(\Dcp\Db\Exception $e) {
313  }
314  $this->assertEquals($count, $test['expect:count'], sprintf("test#%s> Result size is %s while expecting %s. [%s]", $i, $count, $test['expect:count'], print_r($s->getSearchInfo() , true)));
315 
316  if (isset($test['sudo'])) {
317  $this->exitSudo();
318  }
319  }
320  unset($test);
321  }
322  /**
323  * test search filters
324  * @param array $data test specification
325  * @return void
326  * @dataProvider onlyCountFilterCriteria
327  * @depends testCountSearch
328  */
330  {
331  $this->requiresCoreParamEquals('CORE_LANG', 'fr_FR');
332 
333  if (isset($data['import'])) {
334  $this->importDocument($data['import']);
335  }
336 
337  $this->assertTrue(isset($data['tests']) , sprintf("Missing 'tests'."));
338 
339  foreach ($data['tests'] as $i => & $test) {
340  if (isset($test['sudo'])) {
341  $this->sudo($test['sudo']);
342  }
343 
344  $fam = new_doc(self::$dbaccess, $test['search:family']);
345  $this->assertTrue($fam->isAlive() , sprintf("test#%s> Family '%s' not found.", $i, $test['search:family']));
346 
347  $s = new \SearchDoc(self::$dbaccess, $test['search:family']);
348  $s->setObjectReturn();
349  if (isset($test['search:noviewcontrol']) && $data['search:noviewcontrol']) {
350  $s->overrideViewControl();
351  }
352  if (isset($test['search:filters']) && is_array($test['search:filters'])) {
353  foreach ($test['search:filters'] as $filter) {
354  $s->addFilter($filter);
355  }
356  }
357  $count = $s->onlyCount();
358  $this->assertEquals($count, $test['expect:count'], sprintf("test#%s> Result size is %s while expecting %s. [%s]", $i, $count, $test['expect:count'], print_r($s->getSearchInfo() , true)));
359 
360  if (isset($test['sudo'])) {
361  $this->exitSudo();
362  }
363  }
364  unset($test);
365  }
366  /**
367  * test basic search criteria
368  * @param string $criteria filter
369  * @param string $arg filter argument
370  * @param string $family family name or id
371  * @dataProvider countCriteria
372  * @---depends testCountSearch
373  */
374  public function testSliceSearch($criteria, $arg, $family)
375  {
376  $this->createDataSearch();
377  $s = new \SearchDoc(self::$dbaccess, $family);
378  if ($criteria) $s->addFilter($criteria, $arg);
379  $s->setObjectReturn(true);
380  $s->setSlice(2);
381  $s->search();
382  $c = $s->count();
383  $err = $s->getError();
384  $this->assertEmpty($err, sprintf("Search error %s %s", $criteria, $arg));
385  $this->assertLessThanOrEqual(2, $c);
386  }
387  /**
388  * test basic search criteria
389  * @param string $criteria filter
390  * @param string $arg filter argument
391  * @param string $family family name or id
392  * @param integer $count expected results count
393  * @return void
394  * @dataProvider countCriteria
395  * @---depends testCountSearch
396  */
397  public function testStartSearch($criteria, $arg, $family, $count)
398  {
399  $this->createDataSearch();
400 
401  $s = new \SearchDoc(self::$dbaccess, $family);
402  if ($criteria) $s->addFilter($criteria, $arg);
403  $s->setObjectReturn(true);
404  $c = $s->onlyCount();
405  $call = $s->count();
406 
407  $s = new \SearchDoc(self::$dbaccess, $family);
408  if ($criteria) $s->addFilter($criteria, $arg);
409  $s->setObjectReturn(true);
410  $s->setStart(2);
411  $s->search();
412  $cstart = $s->count();
413  $err = $s->getError();
414  $this->assertEmpty($err, sprintf("Search error %s %s", $criteria, $arg));
415  $this->assertLessThanOrEqual($call, $cstart);
416  }
417  /**
418  * test basic search criteria
419  * @param $data
420  * @dataProvider errorCriteria
421  */
422  public function testErrorSearch($data)
423  {
424  try {
425  $s = new \SearchDoc(self::$dbaccess, $data['family']);
426  $s->addFilter($data['criteria'], $data['arg']);
427  if (isset($data['collection'])) {
428  $s->useCollection($data['collection']);
429  }
430  $s->setObjectReturn(true);
431  $s->search();
432 
433  $err = $s->getError();
434  }
435  catch(\Exception $e) {
436  $err = $e->getMessage();
437  }
438  $this->assertFalse($err == "", sprintf("Need detect Search error %s %s", $data['criteria'], $data['arg']));
439  foreach ($data['expectErrors'] as $error) {
440  $this->assertContains($error, $err, sprintf("no good error code"));
441  }
442  }
443  /**
444  * test basic search criteria
445  * @param string $criteria filter
446  * @param string $arg filter argument
447  * @param string $family family name or id
448  * @param integer $count expected results count
449  * @return void
450  * @dataProvider countCriteria
451  */
452  public function testCountAndResetSearch($criteria, $arg, $family, $count)
453  {
454  $this->createDataSearch();
455  $s = new \SearchDoc(self::$dbaccess, $family);
456  $s->onlyCount();
457 
458  if ($criteria) $s->addFilter($criteria, $arg);
459 
460  $t = $s->search();
461 
462  $err = $s->getError();
463  $this->assertEmpty($err, sprintf("Search error %s %s", $criteria, $arg));
464 
465  $this->assertEquals($count, $s->count() , sprintf("Count must be %d (found %d) error %s %s", $count, $s->count() , $criteria, $arg));
466  $this->assertEquals($count, count($t) , sprintf("Count must be %d (found %d) search mode error %s %s", $count, count($t) , $criteria, $arg));
467  }
468  /**
469  * @param $test
470  * @return void
471  * @dataProvider dataGetOriginalQuery
472  */
473  public function testGetOriginalQuery($test)
474  {
475  $fam = empty($test['search:family']) ? '' : $test['search:family'];
476  $s = new \SearchDoc(self::$dbaccess, $fam);
477  if (isset($test['search:filter'])) {
478  if (!is_array($test['search:filter'])) {
479  $test['search:filter'] = array(
480  $test['search:filter']
481  );
482  }
483  foreach ($test['search:filter'] as $filter) {
484  $s->addFilter($filter);
485  }
486  }
487  if (isset($test['search:collection'])) {
488  $s->useCollection($test['search:collection']);
489  }
490  $s->setObjectReturn();
491 
492  $sql = $s->getOriginalQuery();
493  $this->assertNotEmpty($sql, sprintf("Unexpected empty original query!"));
494 
495  $s->search();
496  $err = $s->getError();
497  $this->assertEmpty($err, sprintf("Unexpected SearchDoc error [%s]: %s", $sql, $err));
498 
499  $expected = array();
500  while ($doc = $s->getNextDoc()) {
501  $expected[] = $doc->name;
502  }
503 
505  $this->assertEmpty($err, sprintf("Unexpected error in simpleQuery() [%s]: %s", $sql, $err));
506  foreach ($res as & $row) {
507  $row = $row['name'];
508  }
509 
510  $missing = array_diff($expected, $res);
511  $spurious = array_diff($res, $expected);
512  $this->assertEmpty($missing, sprintf("Unexpected missing elements [%s]: {%s}", $sql, join(', ', $missing)));
513  $this->assertEmpty($spurious, sprintf("Unexpected spurious elements [%s]: {%s}", $sql, join(', ', $spurious)));
514  }
515  /**
516  * @param $famName
517  * @dataProvider dataSearchGetValue
518  */
519  public function testSearchGetValue($famName, $docName, $expectedAttr)
520  {
521  $s = new \SearchDoc("", $famName);
522  $s->setObjectReturn(true);
523  $dl = $s->search()->getDocumentList();
524 
525  foreach ($dl as $doc) {
526  if ($doc->name === $docName) {
527  foreach ($expectedAttr as $attrid => $value) {
528  $this->assertEquals($value, $doc->getRawValue($attrid) , sprintf("attribute \"%s\"", $attrid));
529  }
530  }
531  }
532  }
533 
534  public function dataSearchGetValue()
535  {
536  return array(
537  array(
538  $this->famName,
539  "TST_GETORIGINALQUERY2_3",
540  array(
541  "s_title" => "0",
542  "s_text" => ""
543  )
544  ) ,
545  array(
546  $this->famName,
547  "TST_GETORIGINALQUERY2_2",
548  array(
549  "s_title" => "1£1",
550  "s_text" => "0"
551  )
552  ) ,
553  array(
554  "TST_GETORIGINALQUERY2",
555  "TST_GETORIGINALQUERY2_2",
556  array(
557  "s_title" => "1£1",
558  "s_text" => "0"
559  )
560  ) ,
561  array(
562  "",
563  "TST_GETORIGINALQUERY2_2",
564  array(
565  "s_title" => "1£1",
566  "s_text" => "0"
567  )
568  ) ,
569  array(
570  "",
571  "TST_GETORIGINALQUERY2_1",
572  array(
573  "s_title" => "2",
574  "s_text" => "Two£Four"
575  )
576  )
577  );
578  }
579 
580  public function loginCriteria()
581  {
582  return array(
583  array(
584  "us_login ~* '%s'",
585  "Garfield",
586  "IUSER"
587  ) ,
588  array(
589  "us_mail='%s'",
590  "Léopol",
591  "IUSER"
592  )
593  );
594  }
595  public function errorCriteria()
596  {
597  return array(
598  // family error
599  array(
600  array(
601  'criteria' => "us_login ~* '%s'",
602  'arg' => "Garfield",
603  'family' => "IUSER2",
604  'expectErrors' => array(
605  'IUSER2'
606  )
607  )
608  ) ,
609  // syntax error
610  array(
611  array(
612  'criteria' => "us_mail y '%s'",
613  'arg' => "Léopol",
614  'family' => "IUSER",
615  'expectErrors' => array(
616  'DB0005'
617  )
618  )
619  ) ,
620  // injection error
621  array(
622  array(
623  'criteria' => "us_mail ~ '%s');update users set id=0 where id = -6;--",
624  'arg' => "Léopol",
625  'family' => "IUSER",
626  'expectErrors' => array()
627  )
628  ) ,
629  // useCollection() and addFilter() conflict
630  array(
631  array(
632  'criteria' => "us_login ~* '%s'",
633  'arg' => 'Garfield',
634  'family' => 'IUSER',
635  'collection' => 'TST_GETORIGINALQUERY_SEARCH_SSEARCH_1',
636  'expectErrors' => array(
637  'SD0008'
638  )
639  )
640  )
641  );
642  }
643  public function countCriteria()
644  {
645  return array(
646  array(
647  "title ~* '%s'",
648  "Pomme",
649  $this->famName,
650  2
651  ) ,
652  array(
653  "title is not null",
654  "",
655  $this->famName,
656  6 + 3 + 3 // 3 from ods file
657 
658  ) ,
659  array(
660  "title ~ '%s'",
661  "Poire|Pomme|Cerise|Banane",
662  $this->famName,
663  5
664  ) ,
665  array(
666  "title = '%s'",
667  "Pomme",
668  $this->famName,
669  1
670  )
671  );
672  }
673 
674  public function countAllRevisionCriteria()
675  {
676  return array(
677  array(
678  "latest" => false,
679  "distinct" => false,
680  "trash" => "no",
681  "title ~* '%s'",
682  "Pomme",
683  $this->famName,
684  array(
685  "Pomme",
686  "Pomme-Banane"
687  )
688  ) ,
689  array(
690  "latest" => false,
691  "distinct" => false,
692  "trash" => "no",
693  "title is not null",
694  "",
695  $this->famName,
696  array(
697  "Pruneaux",
698  "Poire",
699  "Poire",
700  "Pomme",
701  "Mures",
702  "Cerise",
703  "Nèfle",
704  "Kiwi",
705  "Coing",
706  "Pomme-Banane",
707  "Banane",
708  "Melon",
709  "Raisin",
710  "Un",
711  "Deux",
712  "Trois",
713  "0",
714  "1£1",
715  "2"
716  )
717  ) ,
718  array(
719  "latest" => false,
720  "distinct" => false,
721  "trash" => "no",
722  "title ~ '%s'",
723  "Poire|Pomme|Cerise|Banane|Prune|Corme",
724  $this->famName,
725  array(
726  "Pruneaux",
727  "Poire",
728  "Poire",
729  "Pomme",
730  "Cerise",
731  "Pomme-Banane",
732  "Banane"
733  )
734  ) ,
735  array(
736  "latest" => false,
737  "distinct" => false,
738  "trash" => "no",
739  "title = '%s'",
740  "Poire",
741  $this->famName,
742  array(
743  "Poire",
744  "Poire"
745  )
746  ) ,
747  array(
748  "latest" => false,
749  "distinct" => true,
750  "trash" => "no",
751  "title ~ '%s'",
752  "Poire|Pomme|Cerise|Banane|Prune|Corme",
753  $this->famName,
754  array(
755  "Poire",
756  "Pomme",
757  "Cerise",
758  "Pomme-Banane",
759  "Banane"
760  )
761  ) ,
762  array(
763  "latest" => true,
764  "distinct" => true,
765  "trash" => "only",
766  "title ~ '%s'",
767  "Poire|Pomme|Cerise|Banane|Prune|Corme",
768  $this->famName,
769  array(
770  "Corme",
771  "Prune"
772  )
773  ) ,
774  array(
775  "latest" => false,
776  "distinct" => false,
777  "trash" => "only",
778  "title ~ '%s'",
779  "Poire|Pomme|Cerise|Orange|Prune|Corme",
780  $this->famName,
781  array(
782  "Corme",
783  "Corme",
784  "Prune",
785  "Orange"
786  )
787  ) ,
788  array(
789  "latest" => false,
790  "distinct" => false,
791  "trash" => "also",
792  "title ~ '%s'",
793  "Poire|Pomme|Cerise|Orange|Prune|Corme",
794  $this->famName,
795  array(
796  "Pruneaux",
797  "Poire",
798  "Poire",
799  "Pomme",
800  "Cerise",
801  "Pomme-Banane",
802  "Corme",
803  "Corme",
804  "Prune",
805  "Orange"
806  )
807  ) ,
808  array(
809  "latest" => false,
810  "distinct" => true,
811  "trash" => "also",
812  "title ~ '%s'",
813  "Pomme|Cerise|Orange|Prune|Corme|Kiwi",
814  $this->famName,
815  array(
816  "Pruneaux",
817  "Pomme",
818  "Cerise",
819  "Pomme-Banane",
820  "Corme",
821  "Prune"
822  )
823  ) ,
824  array(
825  "latest" => true,
826  "distinct" => true,
827  "trash" => "also",
828  "title ~ '%s'",
829  "Pomme|Cerise|Orange|Prune|Corme|Kiwi",
830  $this->famName,
831  array(
832  "Pruneaux",
833  "Pomme",
834  "Cerise",
835  "Pomme-Banane",
836  "Corme",
837  "Prune"
838  )
839  )
840  );
841  }
842 
843  public function countErrorCriteria()
844  {
845  return array(
846  array(
847  "title ~ '%s'",
848  "Poire|Pomme|Cerise|Banane",
849  "BASE_UNKNOW",
850  "BASE_UNKNOW"
851  )
852  );
853  }
854  public function countErrorCriteriaException()
855  {
856  return array(
857  array(
858  "title_unknow ~* '%s'",
859  "Pomme",
860  $this->famName,
861  "title_unknow"
862  ) ,
863  array(
864  "title @? '%s'",
865  "Pomme",
866  $this->famName,
867  "@?"
868  )
869  );
870  }
872  {
873  return array(
874  array(
875  array(
876  "import" => "PU_data_dcp_search_noviewcontrol.ods",
877  "tests" => array(
878  array(
879  "search:family" => "TST_SEARCH_NOVIEWCONTROL",
880  "expect:count" => 6
881  ) ,
882  array(
883  "sudo" => "anonymous",
884  "search:family" => "TST_SEARCH_NOVIEWCONTROL",
885  "expect:count" => 4
886  ) ,
887  array(
888  "import" => "PU_data_dcp_search.ods",
889  "sudo" => "anonymous",
890  "search:family" => "TST_SEARCH_NOVIEWCONTROL",
891  "search:noviewcontrol" => true,
892  "expect:count" => 6
893  )
894  )
895  )
896  )
897  );
898  }
899  public function onlyCountFilterCriteria()
900  {
901  return array(
902  array(
903  array(
904  "import" => "PU_data_dcp_search_filters.ods",
905  "tests" => array(
906  array(
907  "search:family" => "TST_SEARCH_FILTERS",
908  "search:filters" => array(
909  "a_text ~* '^TST_SEARCH_FILTERS_'",
910  "extract(year from a_timestamp) = '1970'"
911  ) ,
912  "expect:count" => 2
913  ) ,
914  array(
915  "search:family" => "TST_SEARCH_FILTERS",
916  "search:filters" => array(
917  "extract(year from a_timestamp) = '1970'",
918  "a_text IN (select * from (values ('TST_SEARCH_FILTERS_01')) as foo(name))"
919  ) ,
920  "expect:count" => 1
921  )
922  )
923  )
924  )
925  );
926  }
927  public function dataGetOriginalQuery()
928  {
929  return array(
930  array(
931  array(
932  'search:family' => '',
933  'search:filter' => "s_title ~ '^T'",
934  'search:collection' => 'TST_GETORIGINALQUERY_SEARCH_3'
935  )
936  ) ,
937  array(
938  array(
939  'search:family' => '',
940  'search:filter' => "s_title ~ '^T'",
941  'search:collection' => 'TST_GETORIGINALQUERY_SEARCH_4'
942  )
943  ) ,
944  array(
945  array(
946  'search:family' => '',
947  'search:filter' => "s_title ~ '^T'",
948  'search:collection' => 'TST_GETORIGINALQUERY_SEARCH_5'
949  )
950  )
951  );
952  }
953 }
static sudo($login)
testOnlyCountErrorSearch($criteria, $arg, $family, $error)
testArrayCountSearch($criteria, $arg, $family, $count)
useCollection($dirid)
static importDocument($file)
if($famId) $s
testCountAndResetSearch($criteria, $arg, $family, $count)
testOnlyCountSearch($criteria, $arg, $family, $count)
testOnlyCountWithNoViewControlSearch($data)
setObjectReturn($returnobject=true)
$d1
Definition: dav.php:11
setSlice($slice)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
testSliceSearch($criteria, $arg, $family)
testSearchGetValue($famName, $docName, $expectedAttr)
testBasicSearch($criteria, $arg, $family)
testOnlyCountErrorSearchException($criteria, $arg, $family, $error)
addFilter($filter, $args= '')
testCountRevisionSearch($latest, $distinct, $trash, $criteria, $arg, $family, array $expectTitles)
$dbaccess
Definition: checkVault.php:17
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
Definition: Lib.Common.php:484
testStartSearch($criteria, $arg, $family, $count)
testCountSearch($criteria, $arg, $family, $count)
if($file) if($subject==""&&$file) if($subject=="") $err
$test
Definition: checkVault.php:30
$latest
$value
setStart($start)
requiresCoreParamEquals($paramName, $requiredValue, $markTestIncomplete=true)
$data
← centre documentaire © anakeen