Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_searchbyfolder.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_foldersearchfamily.ods";
27  }
28  /**
29  * test "usefor" system search
30  * @param string $dirId The identifer of the collection to use
31  * @param array $existsNameList List of documents name that must be returned by the search
32  * @param array $notExistsNameList List of documents name that must NOT be returned by the search
33  * @return void
34  * @dataProvider dataRecurisveSearch
35  */
36  public function testRecurisveSearch($dirId, $famId, $sublevel, $expectedName)
37  {
38  $dir = new_Doc(self::$dbaccess, $dirId);
39  $this->assertTrue($dir->isAlive() , sprintf("Could not get search with id '%s'.", $dirId));
40 
41  $search = new \SearchDoc(self::$dbaccess, $famId);
42  $search->setObjectReturn();
43  $search->useCollection($dirId);
44  $search->setRecursiveSearch(true, $sublevel);
45  $search->search();
46  $res = array();
47  while ($doc = $search->getNextDoc()) {
48  $res[] = $doc->name;
49  }
50 
51  $this->assertEquals(count($expectedName) , $search->count() , sprintf("returns %s\n expected %s", print_r($res, true) , print_r($expectedName, true)));
52 
53  foreach ($expectedName as $name) {
54  $this->assertTrue(in_array($name, $res) , sprintf("%s not found, returns %s\n expected %s", $name, print_r($res, true) , print_r($expectedName, true)));
55  }
56  }
57  /**
58  * test "usefor" system search
59  * @param string $dirId The identifer of the collection to use
60  * @param array $existsNameList List of documents name that must be returned by the search
61  * @param array $notExistsNameList List of documents name that must NOT be returned by the search
62  * @return void
63  * @dataProvider dataRecurisveSearch
64  */
65  public function testCountRecurisveSearch($dirId, $famId, $sublevel, $expectedName)
66  {
67  $dir = new_Doc(self::$dbaccess, $dirId);
68  $this->assertTrue($dir->isAlive() , sprintf("Could not get search with id '%s'.", $dirId));
69 
70  $search = new \SearchDoc(self::$dbaccess, $famId);
71  $search->setObjectReturn();
72  $search->useCollection($dirId);
73  $search->setRecursiveSearch(true, $sublevel);
74  $c = $search->onlyCount();
75 
76  $this->assertEquals(count($expectedName) , $c, sprintf("not expected cound"));
77  }
78  public function dataRecurisveSearch()
79  {
80  return array(
81  array(
82  "dirid" => "TST_SDIR1",
83  "famid" => "",
84  "level" => 10,
85  "names" => array(
86  "TST_ABYFLD1",
87  "TST_ABYFLD2",
88  "TST_ABYFLD3",
89  "TST_ABYFLD4",
90  "TST_ABYFLD5",
91  "TST_BBYFLD1",
92  "TST_BBYFLD2",
93  "TST_BBYFLD3",
94  "TST_BBYFLD4",
95  "TST_BBYFLD5",
96  "TST_SDIR2",
97  "TST_SDIR3",
98  "TST_SDIR4",
99  "TST_SDIR5",
100  )
101  ) ,
102 
103  array(
104  "dirid" => "TST_SDIR1",
105  "famid" => "",
106  "level" => 0,
107  "names" => array(
108  "TST_ABYFLD1",
109  "TST_BBYFLD1",
110  "TST_SDIR2",
111  "TST_SDIR3",
112  )
113  ) ,
114  array(
115  "dirid" => "TST_SDIR1",
116  "famid" => "",
117  "level" => 1,
118  "names" => array(
119  "TST_ABYFLD1",
120  "TST_BBYFLD1",
121  "TST_ABYFLD2",
122  "TST_BBYFLD2",
123  "TST_ABYFLD3",
124  "TST_BBYFLD3",
125  "TST_SDIR2",
126  "TST_SDIR3",
127  "TST_SDIR4",
128  ) ,
129  array(
130  "dirid" => "TST_SDIR1",
131  "famid" => "",
132  "level" => 2,
133  "names" => array(
134  "TST_ABYFLD1",
135  "TST_BBYFLD1",
136  "TST_ABYFLD2",
137  "TST_BBYFLD2",
138  "TST_ABYFLD3",
139  "TST_BBYFLD3",
140  "TST_ABYFLD4",
141  "TST_BBYFLD4",
142  "TST_SDIR2",
143  "TST_SDIR3",
144  "TST_SDIR4",
145  "TST_SDIR5",
146  )
147  ) ,
148  array(
149  "dirid" => "TST_SDIR1",
150  "famid" => "",
151  "level" => 3,
152  "names" => array(
153  "TST_ABYFLD1",
154  "TST_BBYFLD1",
155  "TST_ABYFLD2",
156  "TST_BBYFLD2",
157  "TST_ABYFLD3",
158  "TST_BBYFLD3",
159  "TST_ABYFLD4",
160  "TST_BBYFLD4",
161  "TST_ABYFLD5",
162  "TST_BBYFLD5",
163  "TST_SDIR2",
164  "TST_SDIR3",
165  "TST_SDIR4",
166  "TST_SDIR5",
167  )
168  )
169  ) ,
170  array(
171  "dirid" => "TST_SDIR1",
172  "famid" => "DIR",
173  "level" => 10,
174  "names" => array(
175  "TST_SDIR2",
176  "TST_SDIR3",
177  "TST_SDIR4",
178  "TST_SDIR5"
179  )
180  ) ,
181 
182  array(
183  "dirid" => "TST_SDIR1",
184  "famid" => "DIR",
185  "level" => 0,
186  "names" => array(
187  "TST_SDIR2",
188  "TST_SDIR3"
189  )
190  ) ,
191  array(
192  "dirid" => "TST_SDIR1",
193  "famid" => "TST_BYFOLDER_A",
194  "level" => 1,
195  "names" => array(
196  "TST_ABYFLD1",
197  "TST_ABYFLD2",
198  "TST_ABYFLD3"
199  ) ,
200  array(
201  "dirid" => "TST_SDIR1",
202  "famid" => "TST_BYFOLDER_A",
203  "level" => 2,
204  "names" => array(
205  "TST_BBYFLD1",
206  "TST_BBYFLD2",
207  "TST_BBYFLD3",
208  "TST_BBYFLD4"
209  )
210  ) ,
211  array(
212  "dirid" => "TST_SDIR2",
213  "famid" => "TST_BYFOLDER_A",
214  "level" => 3,
215  "names" => array(
216  "TST_ABYFLD2",
217  "TST_ABYFLD3",
218  "TST_ABYFLD4",
219  "TST_ABYFLD5",
220  )
221  )
222  )
223  );
224  }
225 }
226 ?>
$search
testCountRecurisveSearch($dirId, $famId, $sublevel, $expectedName)
new_Doc($dbaccess, $id= '', $latest=false)
$dir
Definition: resizeimg.php:144
testRecurisveSearch($dirId, $famId, $sublevel, $expectedName)
$dbaccess
Definition: checkVault.php:17
← centre documentaire © anakeen