8 namespace Fossology\Lib\Proxy;
19 protected function setUp() :
void
22 $this->testDb->createPlainTables( array(
'uploadtree',
'report_info') );
23 $this->
dbManager = $this->testDb->getDbManager();
24 $this->
dbManager->queryOnce(
'ALTER TABLE uploadtree RENAME TO uploadtree_a');
25 $this->testDb->insertData(array(
'uploadtree_a'));
26 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
29 protected function tearDown() :
void
31 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
35 public function testGetNonArtifactDescendantsWithMaterialize()
37 $uploadTreeProxy =
new UploadTreeProxy($uploadId=1, $options=array(), $uploadTreeTableName=
'uploadtree_a');
38 $uploadTreeProxy->materialize();
41 $artifactDescendants = $uploadTreeProxy->getNonArtifactDescendants($artifact);
42 assertThat($artifactDescendants, emptyArray());
45 $zipDescendants = $uploadTreeProxy->getNonArtifactDescendants($zip);
46 assertThat(array_keys($zipDescendants), arrayContainingInAnyOrder(array(6,7,8,10,11,12)) );
48 $uploadTreeProxy->unmaterialize();
51 public function testGetNonArtifactDescendantsWithoutMaterialize()
53 $uploadTreeProxy =
new UploadTreeProxy($uploadId=1, $options=array(), $uploadTreeTableName=
'uploadtree_a');
56 $artifactDescendants = $uploadTreeProxy->getNonArtifactDescendants($artifact);
57 assertThat($artifactDescendants, emptyArray());
60 $zipDescendants = $uploadTreeProxy->getNonArtifactDescendants($zip);
61 assertThat(array_keys($zipDescendants), arrayContainingInAnyOrder(array(6,7,8,10,11,12)) );
64 protected function prepareUploadTree($upload=4)
66 $this->
dbManager->prepare($stmt =
'insert.uploadtree',
67 "INSERT INTO uploadtree_a (uploadtree_pk, parent, upload_fk, pfile_fk, ufile_mode, lft, rgt, ufile_name, realparent)"
68 .
" VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)");
70 array(301,
null, $upload,
null, 2<<28, 1, 16,
'topDir',
null)
71 ,array(302, 301, $upload,
null, 2<<28, 2, 5,
'dirA', 301)
72 ,array(303, 302, $upload, 101, 0, 3, 4,
'fileAB.txt', 302)
73 ,array(304, 301, $upload,
null, 3<<28, 6, 13,
'metaC', 301)
74 ,array(305, 304, $upload,
null, 2<<28, 7, 10,
'dirCD', 301)
75 ,array(306, 305, $upload, 102, 0, 8, 9,
'fileCDE.c', 305)
76 ,array(307, 304, $upload, 103, 0,11, 12,
'fileCF.cpp', 301)
77 ,array(308, 301, $upload, 104, 0,14, 15,
'fileG.h', 301)
84 public function testOptionRealParent()
86 $this->prepareUploadTree($upload=4);
88 $uploadTreeProxy =
new UploadTreeProxy($upload, $options=array(UploadTreeProxy::OPT_REALPARENT=>301), $uploadTreeTableName=
'uploadtree_a');
90 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName());
91 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
92 $descendants = $this->
dbManager->fetchAll($res);
94 $zipDescendants = array_reduce($descendants,
function($foo,$bar)
96 $foo[] = $bar[
'uploadtree_pk'];
99 assertThat($zipDescendants, equalTo(array(302,305,307,308)) );
102 public function testOptionRange()
104 $this->prepareUploadTree($upload=4);
106 $itemBounds =
new ItemTreeBounds(302, $uploadTreeTableName=
'uploadtree_a', $upload, 2, 5);
107 $uploadTreeProxyA =
new UploadTreeProxy($upload, array(UploadTreeProxy::OPT_RANGE=>$itemBounds), $uploadTreeTableName,
'viewDirA');
108 $stmt = __METHOD__.
'A';
109 $this->
dbManager->prepare($stmt, $uploadTreeProxyA->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxyA->getDbViewName());
110 $res = $this->
dbManager->execute($stmt, $uploadTreeProxyA->getParams());
111 $descendants = $this->
dbManager->fetchAll($res);
113 $zipDescendantsA = array_reduce($descendants,
function($foo,$bar){
114 $foo[] = $bar[
'uploadtree_pk'];
117 assertThat($zipDescendantsA, equalTo(array(303)) );
119 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
120 $uploadTreeProxyT =
new UploadTreeProxy($upload, array(UploadTreeProxy::OPT_RANGE=>$itemBoundsT), $uploadTreeTableName,
'viewTop');
122 $this->
dbManager->prepare($stmtT, $uploadTreeProxyT->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxyT->getDbViewName());
123 $res = $this->
dbManager->execute($stmt, $uploadTreeProxyT->getParams());
124 $descendantsT = $this->
dbManager->fetchAll($res);
126 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
127 $foo[] = $bar[
'uploadtree_pk'];
130 assertThat($zipDescendantsT, equalTo(array(303,306,307,308)) );
133 public function testOptionExt()
135 $this->prepareUploadTree($upload=4);
137 $uploadTreeProxy =
new UploadTreeProxy($upload, $options=array(UploadTreeProxy::OPT_EXT=>
'c'),
'uploadtree_a');
139 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT ufile_name FROM ".$uploadTreeProxy->getDbViewName());
140 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
141 $descendants = $this->
dbManager->fetchAll($res);
143 $zipDescendants = array_reduce($descendants,
function($foo,$bar){
144 $foo[] = $bar[
'ufile_name'];
147 assertThat($zipDescendants, equalTo(array(
'fileCDE.c')) );
150 public function testOptionHead()
152 $this->prepareUploadTree($upload=4);
154 $uploadTreeProxy =
new UploadTreeProxy($upload, $options=array(UploadTreeProxy::OPT_HEAD=>
'filEc'),
'uploadtree_a');
156 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT ufile_name FROM ".$uploadTreeProxy->getDbViewName());
157 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
158 $descendants = $this->
dbManager->fetchAll($res);
160 $zipDescendants = array_reduce($descendants,
function($foo,$bar){
161 $foo[] = $bar[
'ufile_name'];
164 assertThat($zipDescendants, equalTo(array(
'fileCDE.c',
'fileCF.cpp')) );
167 public function testOptionScanRefParented()
169 $this->testDb->createPlainTables( array(
'license_map',
'license_file') );
171 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
172 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>102,
'agent_fk'=>402));
173 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId+1,
'pfile_fk'=>101,
'agent_fk'=>401));
175 $this->prepareUploadTree($upload=4);
177 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
178 $options = array(UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_AGENT_SET=>array(401), UploadTreeProxy::OPT_SCAN_REF=>$rfId);
179 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName,
'viewTop');
181 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
182 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
183 $descendantsT = $this->
dbManager->fetchAll($res);
185 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
186 $foo[] = $bar[
'pfile_fk'];
189 assertThat($zipDescendantsT, equalTo(array(103)) );
192 public function testOptionScanRefRanged()
194 $this->testDb->createPlainTables( array(
'license_map',
'license_file') );
196 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
197 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>102,
'agent_fk'=>402));
198 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId+1,
'pfile_fk'=>104,
'agent_fk'=>401));
200 $this->prepareUploadTree($upload=4);
202 $options = array(UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_AGENT_SET=>array(401), UploadTreeProxy::OPT_SCAN_REF=>$rfId);
203 $uploadTreeProxy =
new UploadTreeProxy($upload, $options,
'uploadtree_a',
'viewTop');
205 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
206 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
207 $descendantsT = $this->
dbManager->fetchAll($res);
209 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
210 $foo[] = $bar[
'pfile_fk'];
213 assertThat($zipDescendantsT, equalTo(array(103)) );
216 protected function insertDecisionEvent($decisionId,$eventId,$rfId,$groupId,$item,$pfileId,$type,$removed,$date,$scope=DecisionScopes::ITEM)
218 $this->
dbManager->insertTableRow(
'clearing_decision',array(
'clearing_decision_pk'=>$decisionId,
'pfile_fk'=>$pfileId,
'uploadtree_fk'=>$item,
219 'group_fk'=>$groupId,
'date_added'=>$date,
'decision_type'=> $type,
'scope'=>$scope));
220 $this->
dbManager->insertTableRow(
'clearing_event',array(
'clearing_event_pk'=>$eventId,
'rf_fk'=>$rfId,
'group_fk'=>$groupId,
'uploadtree_fk'=>$item,
221 'date_added'=>$date,
'removed'=>$removed));
222 if ($type != DecisionTypes::WIP) {
223 $this->
dbManager->insertTableRow(
'clearing_decision_event', array(
'clearing_event_fk' => $eventId,
'clearing_decision_fk' => $decisionId));
227 public function testOptionConRefParented()
229 $this->testDb->createPlainTables( array(
'clearing_decision',
'clearing_decision_event',
'clearing_event') );
236 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
237 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:15');
239 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
240 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:15');
242 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
243 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::WIP,
'true',
'2015-05-11 12:15');
245 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 303, 101, DecisionTypes::WIP,
'false',
'2015-05-11 12:15');
247 $this->prepareUploadTree($upload=4);
249 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_CONCLUDE_REF=>$rfId);
250 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName=
'uploadtree_a',
'viewTop');
252 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName());
253 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
254 $descendantsT = $this->
dbManager->fetchAll($res);
256 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
257 $foo[] = $bar[
'uploadtree_pk'];
261 assertThat($zipDescendantsT, equalTo(array($parentOf306,308)) );
264 public function testOptionConRefRanged()
266 $this->testDb->createPlainTables( array(
'clearing_decision',
'clearing_decision_event',
'clearing_event') );
273 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
274 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:15');
276 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
277 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:15');
279 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
280 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 308, 104, DecisionTypes::WIP,
'true',
'2015-05-11 12:15');
282 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 303, 101, DecisionTypes::WIP,
'false',
'2015-05-11 12:15');
284 $this->prepareUploadTree($upload=4);
286 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
287 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_CONCLUDE_REF=>$rfId);
288 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName,
'viewTop');
290 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName());
291 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
292 $descendantsT = $this->
dbManager->fetchAll($res);
294 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
295 $foo[] = $bar[
'uploadtree_pk'];
298 assertThat($zipDescendantsT, equalTo(array(306,308)) );
301 public function testOptionSkipAlreadyClearedRanged()
303 $this->testDb->createPlainTables( array(
'license_file',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_ref') );
304 $this->testDb->createInheritedTables( array(
'license_candidate') );
311 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId,
'rf_shortname'=>
'any_license_found'));
313 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
314 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
316 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
317 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>104,
'agent_fk'=>401));
319 $this->prepareUploadTree($upload=4);
321 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
322 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT, UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED=>
true, UploadTreeProxy::OPT_AGENT_SET=>array(401));
323 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName,
'viewTop');
325 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
326 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
327 $descendantsT = $this->
dbManager->fetchAll($res);
329 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
330 $foo[] = $bar[
'pfile_fk'];
333 assertThat($zipDescendantsT, equalTo(array(104)) );
336 public function testOptionSkipAlreadyClearedParented()
338 $this->testDb->createPlainTables( array(
'license_file',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_ref') );
339 $this->testDb->createInheritedTables( array(
'license_candidate') );
346 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId,
'rf_shortname'=>
'any_license_found'));
348 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
349 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
351 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
352 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>104,
'agent_fk'=>401));
354 $this->prepareUploadTree($upload=4);
356 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_REALPARENT=>301, UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED=>
true, UploadTreeProxy::OPT_AGENT_SET=>array(401));
357 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName=
'uploadtree_a',
'viewTop');
359 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
360 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
361 $descendantsT = $this->
dbManager->fetchAll($res);
363 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
364 $foo[] = $bar[
'pfile_fk'];
367 assertThat($zipDescendantsT, equalTo(array(104)) );
370 public function testOptionSkipTheseThatAreAlreadyCleared()
372 $this->testDb->createPlainTables( array(
'license_file',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_ref') );
373 $this->testDb->createInheritedTables( array(
'license_candidate') );
380 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId,
'rf_shortname'=>
'any_license_found'));
382 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
383 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
385 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
386 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>104,
'agent_fk'=>401));
388 $this->prepareUploadTree($upload=4);
390 $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));
391 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName=
'uploadtree_a',
'viewTop');
393 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
394 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
395 $descendantsT = $this->
dbManager->fetchAll($res);
397 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
398 $foo[] = $bar[
'pfile_fk'];
401 assertThat($zipDescendantsT, equalTo(array(104)) );
404 public function testOptionSkipAlreadyClearedButScanRanged()
406 $this->testDb->createPlainTables( array(
'license_file',
'clearing_decision',
'clearing_decision_event',
'clearing_event',
'license_ref',
'license_map') );
407 $this->testDb->createInheritedTables( array(
'license_candidate') );
414 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId,
'rf_shortname'=>
'any_license_found'));
415 $this->
dbManager->insertTableRow(
'license_ref',array(
'rf_pk'=>$rfId+1,
'rf_shortname'=>
'license_found'));
417 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 307, 103, DecisionTypes::IDENTIFIED,
'false',
'2015-05-11 12:13');
418 $this->insertDecisionEvent($decisionId++, $eventId++, $rfId, $groupId, 306, 102, DecisionTypes::IDENTIFIED,
'true',
'2015-05-11 12:13');
420 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>103,
'agent_fk'=>401));
421 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId,
'pfile_fk'=>104,
'agent_fk'=>401));
422 $this->
dbManager->insertTableRow(
'license_file',array(
'rf_fk'=>$rfId+1,
'pfile_fk'=>101,
'agent_fk'=>401));
424 $this->prepareUploadTree($upload=4);
426 $itemBoundsT =
new ItemTreeBounds(301, $uploadTreeTableName=
'uploadtree_a', $upload, 1, 16);
427 $options = array(UploadTreeProxy::OPT_GROUP_ID=>$groupId, UploadTreeProxy::OPT_RANGE=>$itemBoundsT,
428 UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED=>
true, UploadTreeProxy::OPT_AGENT_SET=>array(401), UploadTreeProxy::OPT_SCAN_REF=>$rfId);
429 $uploadTreeProxy =
new UploadTreeProxy($upload, $options, $uploadTreeTableName,
'viewTop');
431 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT pfile_fk FROM ".$uploadTreeProxy->getDbViewName());
432 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
433 $descendantsT = $this->
dbManager->fetchAll($res);
435 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
436 $foo[] = $bar[
'pfile_fk'];
439 assertThat($zipDescendantsT, equalTo(array(104)) );
442 public function testCount()
445 assertThat($uploadTreeProxy->count(), is(12));
447 $uploadTreeProxy->materialize();
448 assertThat($uploadTreeProxy->count(), is(12));
450 $uploadTreeProxyAd =
new UploadTreeProxy(1, array(UploadTreeProxy::OPT_ITEM_FILTER=>
" AND ufile_name LIKE 'Ad%'"),
'uploadtree_a',
'viewWithHead');
451 assertThat($uploadTreeProxyAd->count(), is(2));
454 public function testGetUploadTreeTableName()
456 $uploadTreeProxy =
new UploadTreeProxy(1, array(), $tableName=
'uploadtree_a');
457 assertThat($uploadTreeProxy->getUploadTreeTableName(), is(equalTo($tableName)));
460 public function testGetDefaultUploadTreeView()
462 $this->prepareUploadTree($upload=4);
463 $options = array(UploadTreeProxy::OPT_ITEM_FILTER=>
"AND ufile_name='dirA'");
464 $uploadTreeProxy =
new UploadTreeProxy(4, $options, $uploadTreeTableName=
'uploadtree_a');
467 $this->
dbManager->prepare($stmt, $uploadTreeProxy->asCTE().
" SELECT uploadtree_pk FROM ".$uploadTreeProxy->getDbViewName());
468 $res = $this->
dbManager->execute($stmt, $uploadTreeProxy->getParams());
469 $descendantsT = $this->
dbManager->fetchAll($res);
471 $zipDescendantsT = array_reduce($descendantsT,
function($foo,$bar){
472 $foo[] = $bar[
'uploadtree_pk'];
475 assertThat($zipDescendantsT, equalTo(array(302)) );
fo_dbManager * dbManager
fo_dbManager object