29 protected function setUp()
32 $this->testDb->createPlainTables( array(
'uploadtree') );
33 $this->
dbManager = $this->testDb->getDbManager();
34 $this->
dbManager->queryOnce(
'ALTER TABLE uploadtree RENAME TO uploadtree_a');
35 $this->testDb->insertData(array(
'uploadtree_a'));
36 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
39 protected function tearDown()
41 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
45 public function testGetNonArtifactDescendantsWithMaterialize()
47 $uploadTreeProxy =
new UploadTreeProxy($uploadId=1, $options=array(), $uploadTreeTableName=
'uploadtree_a');
48 $uploadTreeProxy->materialize();
51 $artifactDescendants = $uploadTreeProxy->getNonArtifactDescendants($artifact);
52 assertThat($artifactDescendants, emptyArray());
55 $zipDescendants = $uploadTreeProxy->getNonArtifactDescendants($zip);
56 assertThat(array_keys($zipDescendants), arrayContainingInAnyOrder(array(6,7,8,10,11,12)) );
58 $uploadTreeProxy->unmaterialize();
61 public function testGetNonArtifactDescendantsWithoutMaterialize()
63 $uploadTreeProxy =
new UploadTreeProxy($uploadId=1, $options=array(), $uploadTreeTableName=
'uploadtree_a');
66 $artifactDescendants = $uploadTreeProxy->getNonArtifactDescendants($artifact);
67 assertThat($artifactDescendants, emptyArray());
70 $zipDescendants = $uploadTreeProxy->getNonArtifactDescendants($zip);
71 assertThat(array_keys($zipDescendants), arrayContainingInAnyOrder(array(6,7,8,10,11,12)) );
74 protected function prepareUploadTree($upload=4)
76 $this->
dbManager->prepare($stmt =
'insert.uploadtree',
77 "INSERT INTO uploadtree_a (uploadtree_pk, parent, upload_fk, pfile_fk, ufile_mode, lft, rgt, ufile_name, realparent)" 78 .
" VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)");
80 array(301, null, $upload, null, 2<<28, 1, 16,
'topDir',null)
81 ,array(302, 301, $upload, null, 2<<28, 2, 5,
'dirA', 301)
82 ,array(303, 302, $upload, 101, 0, 3, 4,
'fileAB.txt', 302)
83 ,array(304, 301, $upload, null, 3<<28, 6, 13,
'metaC', 301)
84 ,array(305, 304, $upload, null, 2<<28, 7, 10,
'dirCD', 301)
85 ,array(306, 305, $upload, 102, 0, 8, 9,
'fileCDE.c', 305)
86 ,array(307, 304, $upload, 103, 0,11, 12,
'fileCF.cpp', 301)
87 ,array(308, 301, $upload, 104, 0,14, 15,
'fileG.h', 301)
94 public function testOptionRealParent()
96 $this->prepareUploadTree($upload=4);
98 $uploadTreeProxy =
new UploadTreeProxy($upload, $options=array(UploadTreeProxy::OPT_REALPARENT=>301), $uploadTreeTableName=
'uploadtree_a');
100 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName());
101 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
102 $descendants = $this->
dbManager->fetchAll($res);
104 $zipDescendants = array_reduce($descendants,
function($foo,$bar)
106 $foo[] = $bar[
'uploadtree_pk'];
109 assertThat($zipDescendants, equalTo(array(302,305,307,308)) );
112 public function testOptionRange()
114 $this->prepareUploadTree($upload=4);
116 $itemBounds =
new ItemTreeBounds(302, $uploadTreeTableName=
'uploadtree_a', $upload, 2, 5);
117 $uploadTreeProxyA =
new UploadTreeProxy($upload, array(UploadTreeProxy::OPT_RANGE=>$itemBounds), $uploadTreeTableName,
'viewDirA');
118 $stmt = __METHOD__.
'A';
119 $this->
dbManager->prepare($stmt, $uploadTreeProxyA->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxyA->getDbViewName());
120 $res = $this->
dbManager->execute($stmt, $uploadTreeProxyA->getParams());
121 $descendants = $this->
dbManager->fetchAll($res);
123 $zipDescendantsA = array_reduce($descendants,
function($foo,$bar){
124 $foo[] = $bar[
'uploadtree_pk'];
127 assertThat($zipDescendantsA, equalTo(array(303)) );
129 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
130 $uploadTreeProxyT =
new UploadTreeProxy($upload, array(UploadTreeProxy::OPT_RANGE=>$itemBoundsT), $uploadTreeTableName,
'viewTop');
132 $this->
dbManager->prepare($stmtT, $uploadTreeProxyT->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxyT->getDbViewName());
133 $res = $this->
dbManager->execute($stmt, $uploadTreeProxyT->getParams());
134 $descendantsT = $this->
dbManager->fetchAll($res);
136 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
137 $foo[] = $bar[
'uploadtree_pk'];
140 assertThat($zipDescendantsT, equalTo(array(303,306,307,308)) );
143 public function testOptionExt()
145 $this->prepareUploadTree($upload=4);
147 $uploadTreeProxy =
new UploadTreeProxy($upload, $options=array(UploadTreeProxy::OPT_EXT=>
'c'),
'uploadtree_a');
149 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT ufile_name FROM ".$uploadTreeProxy->getDbViewName());
150 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
151 $descendants = $this->
dbManager->fetchAll($res);
153 $zipDescendants = array_reduce($descendants,
function($foo,$bar){
154 $foo[] = $bar[
'ufile_name'];
157 assertThat($zipDescendants, equalTo(array(
'fileCDE.c')) );
160 public function testOptionHead()
162 $this->prepareUploadTree($upload=4);
164 $uploadTreeProxy =
new UploadTreeProxy($upload, $options=array(UploadTreeProxy::OPT_HEAD=>
'filEc'),
'uploadtree_a');
166 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT ufile_name FROM ".$uploadTreeProxy->getDbViewName());
167 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
168 $descendants = $this->
dbManager->fetchAll($res);
170 $zipDescendants = array_reduce($descendants,
function($foo,$bar){
171 $foo[] = $bar[
'ufile_name'];
174 assertThat($zipDescendants, equalTo(array(
'fileCDE.c',
'fileCF.cpp')) );
177 public function testOptionScanRefParented()
179 $this->testDb->createPlainTables( array(
'license_map',
'license_file') );
181 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
182 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>102,
'agent_fk'=>402));
183 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId+1,
'pfile_fk'=>101,
'agent_fk'=>401));
185 $this->prepareUploadTree($upload=4);
187 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
188 $options = array(UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_AGENT_SET=>array(401), UploadTreeProxy::OPT_SCAN_REF=>$rfId);
189 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName,
'viewTop');
191 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
192 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
193 $descendantsT = $this->
dbManager->fetchAll($res);
195 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
196 $foo[] = $bar[
'pfile_fk'];
199 assertThat($zipDescendantsT, equalTo(array(103)) );
202 public function testOptionScanRefRanged()
204 $this->testDb->createPlainTables( array(
'license_map',
'license_file') );
206 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
207 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>102,
'agent_fk'=>402));
208 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId+1,
'pfile_fk'=>104,
'agent_fk'=>401));
210 $this->prepareUploadTree($upload=4);
212 $options = array(UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_AGENT_SET=>array(401), UploadTreeProxy::OPT_SCAN_REF=>$rfId);
213 $uploadTreeProxy =
new UploadTreeProxy($upload, $options,
'uploadtree_a',
'viewTop');
215 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
216 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
217 $descendantsT = $this->
dbManager->fetchAll($res);
219 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
220 $foo[] = $bar[
'pfile_fk'];
223 assertThat($zipDescendantsT, equalTo(array(103)) );
226 protected function insertDecisionEvent($decisionId,$eventId,$rfId,$groupId,$item,$pfileId,$type,$removed,$date)
228 $this->
dbManager->insertTableRow(
'clearing_decision',array(
'clearing_decision_pk'=>$decisionId,
'pfile_fk'=>$pfileId,
'uploadtree_fk'=>$item,
229 'group_fk'=>$groupId,
'date_added'=>$date,
'decision_type'=> $type));
230 $this->
dbManager->insertTableRow(
'clearing_event',array(
'clearing_event_pk'=>$eventId,
'rf_fk'=>$rfId,
'group_fk'=>$groupId,
'uploadtree_fk'=>$item,
231 'date_added'=>$date,
'removed'=>$removed));
232 if ($type != DecisionTypes::WIP) {
233 $this->
dbManager->insertTableRow(
'clearing_decision_event', array(
'clearing_event_fk' => $eventId,
'clearing_decision_fk' => $decisionId));
237 public function testOptionConRefParented()
239 $this->testDb->createPlainTables( array(
'clearing_decision',
'clearing_decision_event',
'clearing_event') );
246 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
247 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:15');
249 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
250 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:15');
252 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
253 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::WIP,
'true',
'2015-05-11 12:15');
255 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 303, 101, DecisionTypes::WIP,
'false',
'2015-05-11 12:15');
257 $this->prepareUploadTree($upload=4);
259 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_CONCLUDE_REF=>$rfId);
260 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName=
'uploadtree_a',
'viewTop');
262 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName());
263 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
264 $descendantsT = $this->
dbManager->fetchAll($res);
266 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
267 $foo[] = $bar[
'uploadtree_pk'];
271 assertThat($zipDescendantsT, equalTo(array($parentOf306,308)) );
274 public function testOptionConRefRanged()
276 $this->testDb->createPlainTables( array(
'clearing_decision',
'clearing_decision_event',
'clearing_event') );
283 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
284 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:15');
286 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
287 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:15');
289 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
290 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::WIP,
'true',
'2015-05-11 12:15');
292 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 303, 101, DecisionTypes::WIP,
'false',
'2015-05-11 12:15');
294 $this->prepareUploadTree($upload=4);
296 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
297 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_CONCLUDE_REF=>$rfId);
298 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName,
'viewTop');
300 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName());
301 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
302 $descendantsT = $this->
dbManager->fetchAll($res);
304 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
305 $foo[] = $bar[
'uploadtree_pk'];
308 assertThat($zipDescendantsT, equalTo(array(306,308)) );
311 public function testOptionSkipAlreadyClearedRanged()
313 $this->testDb->createPlainTables( array(
'license_file',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_ref') );
320 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId,
'rf_shortname'=>
'any_license_found'));
322 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
323 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
325 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
326 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>104,
'agent_fk'=>401));
328 $this->prepareUploadTree($upload=4);
330 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
331 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED=>
true, UploadTreeProxy::OPT_AGENT_SET=>array(401));
332 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName,
'viewTop');
334 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
335 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
336 $descendantsT = $this->
dbManager->fetchAll($res);
338 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
339 $foo[] = $bar[
'pfile_fk'];
342 assertThat($zipDescendantsT, equalTo(array(104)) );
345 public function testOptionSkipAlreadyClearedParented()
347 $this->testDb->createPlainTables( array(
'license_file',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_ref') );
354 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId,
'rf_shortname'=>
'any_license_found'));
356 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
357 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
359 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
360 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>104,
'agent_fk'=>401));
362 $this->prepareUploadTree($upload=4);
364 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED=>
true, UploadTreeProxy::OPT_AGENT_SET=>array(401));
365 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName=
'uploadtree_a',
'viewTop');
367 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
368 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
369 $descendantsT = $this->
dbManager->fetchAll($res);
371 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
372 $foo[] = $bar[
'pfile_fk'];
375 assertThat($zipDescendantsT, equalTo(array(104)) );
378 public function testOptionSkipTheseThatAreAlreadyCleared()
380 $this->testDb->createPlainTables( array(
'license_file',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_ref') );
387 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId,
'rf_shortname'=>
'any_license_found'));
389 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
390 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
392 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
393 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>104,
'agent_fk'=>401));
395 $this->prepareUploadTree($upload=4);
397 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_SKIP_THESE=>UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED, UploadTreeProxy::OPT_AGENT_SET=>array(401));
398 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName=
'uploadtree_a',
'viewTop');
400 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
401 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
402 $descendantsT = $this->
dbManager->fetchAll($res);
404 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
405 $foo[] = $bar[
'pfile_fk'];
408 assertThat($zipDescendantsT, equalTo(array(104)) );
411 public function testOptionSkipAlreadyClearedButScanRanged()
413 $this->testDb->createPlainTables( array(
'license_file',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_ref',
'license_map') );
420 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId,
'rf_shortname'=>
'any_license_found'));
421 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId+1,
'rf_shortname'=>
'license_found'));
423 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
424 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
426 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
427 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>104,
'agent_fk'=>401));
428 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId+1,
'pfile_fk'=>101,
'agent_fk'=>401));
430 $this->prepareUploadTree($upload=4);
432 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
433 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT,
434 UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED=>
true, UploadTreeProxy::OPT_AGENT_SET=>array(401), UploadTreeProxy::OPT_SCAN_REF=>$rfId);
435 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName,
'viewTop');
437 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
438 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
439 $descendantsT = $this->
dbManager->fetchAll($res);
441 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
442 $foo[] = $bar[
'pfile_fk'];
445 assertThat($zipDescendantsT, equalTo(array(104)) );
448 public function testCount()
451 assertThat($uploadTreeProxy->count(), is(12));
453 $uploadTreeProxy->materialize();
454 assertThat($uploadTreeProxy->count(), is(12));
456 $uploadTreeProxyAd =
new UploadTreeProxy(1, array(UploadTreeProxy::OPT_ITEM_FILTER=>
" AND ufile_name LIKE 'Ad%'"),
'uploadtree_a',
'viewWithHead');
457 assertThat($uploadTreeProxyAd->count(), is(2));
460 public function testGetUploadTreeTableName()
462 $uploadTreeProxy =
new UploadTreeProxy(1, array(), $tableName=
'uploadtree_a');
463 assertThat($uploadTreeProxy->getUploadTreeTableName(), is(equalTo($tableName)));
466 public function testGetDefaultUploadTreeView()
468 $this->prepareUploadTree($upload=4);
469 $options = array(UploadTreeProxy::OPT_ITEM_FILTER=>
"AND ufile_name='dirA'");
470 $uploadTreeProxy =
new UploadTreeProxy(4, $options, $uploadTreeTableName=
'uploadtree_a');
473 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName());
474 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
475 $descendantsT = $this->
dbManager->fetchAll($res);
477 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
478 $foo[] = $bar[
'uploadtree_pk'];
481 assertThat($zipDescendantsT, equalTo(array(302)) );
fo_dbManager * dbManager
fo_dbManager object