Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_searchfamilies.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 
13 require_once 'PU_testcase_dcp_commonfamily.php';
14 /**
15  * test some SearchDoc option like generalFilter
16  */
18 {
19  /**
20  * import TST_FULLSERACHFAM1 family and some documents
21  * @static
22  * @return string
23  */
24  protected static function getCommonImportFile()
25  {
26  return "PU_data_dcp_searchfamilies.ods";
27  }
28  /**
29  * @dataProvider dataProperties
30  */
31  public function testProperties($filterName, array $expectedProperties)
32  {
33  $s = new \SearchDoc(self::$dbaccess);
34  if ($filterName) {
35  $s->addFilter("name = '%s'", $filterName);
36  }
37  $s->setObjectReturn(true);
38  $s->search();
39 
40  $err = $s->getError();
41  $this->assertEmpty($err, "search error : $err");
42  $dl = $s->getDocumentList();
43  // print_r($s->getSearchInfo());
44  $this->assertEquals(1, $s->count() , "Family $filterName not found - " . print_r($s->getSearchInfo() , true));
45 
46  $index = 0;
47 
48  $doc = $s->getNextDoc();
49  /**
50  * @var \Doc $doc
51  */
52  foreach ($expectedProperties as $propId => $expectedValue) {
53  $propValue = $doc->getPropertyValue($propId);
54  if ($propValue === false) {
55  $propValue = $doc->getRawValue($propId);
56  }
57  if (abs($propValue) > 0) {
58  if (!is_numeric($expectedValue)) {
59  $propValueName = getNameFromId(self::$dbaccess, abs($propValue));
60  if ($propValueName != '') {
61  $propValue = $propValueName;
62  }
63  }
64  }
65  $this->assertEquals($expectedValue, $propValue, sprintf("Not the good property for \"$propId\""));
66  }
67  }
68 
69  public function dataProperties()
70  {
71  return array(
72  array(
73  'famName' => "TST_SFAM1",
74  "props" => array(
75  "name" => "TST_SFAM1",
76  "profid" => "TSTFAM_ADMIN_1",
77  "cprofid" => "TSTFAM_ADMIN_EDIT1",
78  "ccvid" => "TSTFAM_CV_1",
79  "schar" => "S"
80  )
81  ) ,
82  array(
83  'famName' => "TST_SFAM2",
84  "props" => array(
85  "name" => "TST_SFAM2",
86  "profid" => "TSTFAM_ADMIN_2",
87  "cprofid" => "TSTFAM_ADMIN_EDIT2",
88  "ccvid" => "TSTFAM_CV_2",
89  "schar" => "",
90  "maxrev" => 34
91  )
92  )
93  );
94  }
95 }
96 ?>
if($famId) $s
getNameFromId($dbaccess, $id)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen