35 protected function setUp()
38 $this->
dbManager = &$this->testDb->getDbManager();
40 $this->testDb->createPlainTables(array(
'upload',
'uploadtree'));
42 $this->
dbManager->prepare($stmt =
'insert.upload',
43 "INSERT INTO upload (upload_pk, uploadtree_tablename) VALUES ($1, $2)");
44 $uploadArray = array(array(1,
'uploadtree'), array(32,
'uploadtree'));
45 foreach ($uploadArray as $uploadEntry) {
49 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
52 protected function tearDown()
54 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
60 public function testGetMinimalCoveringItem()
63 $coverContainer = $this->treeDao->getMinimalCoveringItem(1,
"uploadtree");
64 assertThat($coverContainer,equalTo(5));
66 $this->
prepareUploadTree(array(array($item=99,null,$upload=32,88,0x0,1,2,
'plainFile',null)));
67 $coverSelf = $this->treeDao->getMinimalCoveringItem($upload,
"uploadtree");
68 assertThat($coverSelf,equalTo($item));
71 public function testGetFullPathFromSingleFolderUpload()
74 $cover = $this->treeDao->getMinimalCoveringItem(1,
"uploadtree");
75 assertThat($cover,equalTo(5));
77 $path = $this->treeDao->getFullPath(6,
"uploadtree", $cover);
78 assertThat($path,equalTo($fName));
80 $path = $this->treeDao->getFullPath(6,
"uploadtree", $cover,
true);
81 assertThat($path,equalTo($fName));
84 public function testGetFullPathFromSingleFolderUploadWithDropArtifact()
87 $cover = $this->treeDao->getMinimalCoveringItem(1,
"uploadtree",
true);
88 assertThat($cover,equalTo(5));
89 $path = $this->treeDao->getFullPath(6,
"uploadtree", $cover);
90 assertThat($path,equalTo($fName));
93 public function testGetFullPathFromSingleFolderUploadWithAFileOutside()
96 array(6,5,1,0,0,5,6,
"file",5),
97 array(11,4,1,0,0,11,12,
"file2",3)
99 $cover = $this->treeDao->getMinimalCoveringItem(1,
"uploadtree");
100 assertThat($cover,equalTo(4));
102 $pathInsideArchive = $this->treeDao->getFullPath(6,
"uploadtree", $cover);
103 assertThat($pathInsideArchive,equalTo(
"archive/file"));
105 $pathInsideArchive = $this->treeDao->getFullPath(6,
"uploadtree", $cover,
true);
106 assertThat($pathInsideArchive,equalTo(
"archive/file"));
108 $pathOutsideArchive = $this->treeDao->getFullPath(11,
"uploadtree", $cover);
109 assertThat($pathOutsideArchive,equalTo(
"file2"));
111 $pathOutsideArchive = $this->treeDao->getFullPath(11,
"uploadtree", $cover,
true);
112 assertThat($pathOutsideArchive,equalTo(
"file2"));
121 $this->
dbManager->prepare($stmt =
'insert.uploadtree',
122 "INSERT INTO uploadtree (uploadtree_pk, parent, upload_fk, pfile_fk, ufile_mode, lft, rgt, ufile_name, realparent) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)");
123 foreach ($uploadTreeArray as $uploadTreeEntry) {
135 $right_base = 5 + count($subentries) * 2;
137 $uploadTreeArray = array_merge(
139 array(1, null, 1, 1, 0x20008400, 1, $right_base + 5,
'archive.tar.gz', null),
140 array(2, 1, 1, 0, 0x30004400, 2, $right_base + 4,
'artifact.dir', 1),
141 array(3, 2, 1, 2, 0x20008000, 3, $right_base + 3,
'archive.tar', 1),
142 array(4, 3, 1, 0, 0x30004400, 4, $right_base + 2,
'artifact.dir', 3),
143 array(5, 4, 1, 0, 0x20004400, 5, $right_base + 1,
'archive', 3)),
192 array(3675, 3674, 32, 3299, 33188, 23, 24,
'N3',3674),
193 array(3674, 3652, 32, 0, 0x20004400, 22, 37,
'N',3652),
194 array(3673, 3652, 32, 3298, 33188, 38, 39,
'O',3652),
195 array(3671, 3669, 32, 3296, 33188, 9, 10,
'J',3669),
196 array(3669, 3652, 32, 0, 0x20004400, 4, 11,
'H',3652),
197 array(3668, 3652, 32, 3294, 33188, 42, 43,
'C',3652),
198 array(3662, 3661, 32, 0, 0x20004400, 45, 48,
'L3',3661),
199 array(3666, 3661, 32, 0, 0x20004400, 49, 52,
'L1',3661),
200 array(3665, 3664, 32, 3292, 33188, 54, 55,
'L2a',3664),
201 array(3664, 3661, 32, 0, 0x20004400, 53, 56,
'L2',3661),
202 array(3661, 3652, 32, 0, 0x20004400, 44, 57,
'L',3652),
203 array(3658, 3657, 32, 3288, 33188, 60, 61,
'P2a',3657),
204 array(3657, 3656, 32, 0, 0x20004400, 59, 62,
'P2',3656),
205 array(3660, 3656, 32, 3290, 33188, 65, 66,
'P3',6356),
206 array(3656, 3652, 32, 0, 0x20004400, 58, 67,
'P',3652),
207 array(3655, 3654, 32, 0, 0x20004400, 69, 70,
'M1',3654),
208 array(3654, 3652, 32, 0, 0x20004400, 68, 71,
'M',3652),
209 array(3653, 3652, 32, 3287, 33188, 72, 73,
'A',3652),
210 array(3652, 3651, 32, 0, 0x20004400, 3, 74,
'uploadDaoTest',3650),
211 array(3651, 3650, 32, 0, 0x30004400, 2, 75,
'artifact.dir',3650),
212 array(3650, NULL, 32, 3286, 0x20008400, 1, 76,
'uploadDaoTest.tar',null),
213 array(3686, 3652, 32, 3306, 33188, 12, 13,
'R',3652),
214 array(3683, 3682, 32, 3303, 33188, 15, 16,
'E',3682),
215 array(3685, 3682, 32, 3305, 33188, 17, 18,
'G',3682),
216 array(3682, 3652, 32, 0, 0x20004400, 14, 21,
'D',3652),
217 array(3677, 3674, 32, 3300, 33188, 25, 26,
'N5',3674),
218 array(3676, 3674, 32, 3293, 33188, 27, 28,
'N1',3674),
219 array(3678, 3674, 32, 0, 0x20004400, 29, 32,
'N2',3674),
220 array(3681, 3680, 32, 3302, 33188, 34, 35,
'N4a',3680),
221 array(3680, 3674, 32, 0, 0x20004400, 33, 36,
'N4',3674),
225 public function testGetFullPathWithComlpexStructureFromFolder()
228 $cover = $this->treeDao->getMinimalCoveringItem(32,
"uploadtree");
229 assertThat($cover,equalTo(3652));
230 assertThat($this->treeDao->getFullPath(3666,
"uploadtree", $cover), equalTo(
"L/L1"));
231 assertThat($this->treeDao->getFullPath(3666,
"uploadtree", $cover,
true), equalTo(
"L/L1"));
234 public function testGetFullPathWithComlpexStructureFromFile()
237 $cover = $this->treeDao->getMinimalCoveringItem(32,
"uploadtree");
238 assertThat($cover,equalTo(3652));
240 assertThat($this->treeDao->getFullPath(3665,
"uploadtree", $cover), equalTo(
"L/L2/L2a"));
241 assertThat($this->treeDao->getFullPath(3665,
"uploadtree", $cover,
true), equalTo(
"L/L2/L2a"));
243 assertThat($this->treeDao->getFullPath(3665,
"uploadtree"), equalTo(
"uploadDaoTest.tar/uploadDaoTest/L/L2/L2a"));
244 assertThat($this->treeDao->getFullPath(3665,
"uploadtree",0,
true), equalTo(
"uploadDaoTest/L/L2/L2a"));
247 public function testGetFullPathWithComlpexStructureFromFileAndOtherUpload()
251 $cover = $this->treeDao->getMinimalCoveringItem(32,
"uploadtree");
252 assertThat($cover,equalTo(3652));
253 assertThat($this->treeDao->getFullPath(3665,
"uploadtree", $cover), equalTo(
"L/L2/L2a"));
254 assertThat($this->treeDao->getFullPath(3665,
"uploadtree", $cover,
true), equalTo(
"L/L2/L2a"));
255 assertThat($this->treeDao->getFullPath(3665,
"uploadtree"), equalTo(
"uploadDaoTest.tar/uploadDaoTest/L/L2/L2a"));
256 assertThat($this->treeDao->getFullPath(3665,
"uploadtree",0,
true), equalTo(
"uploadDaoTest/L/L2/L2a"));
259 public function testGetUploadHashes()
261 $this->testDb->createPlainTables(array(
'pfile'));
262 $this->
dbManager->queryOnce(
'ALTER TABLE uploadtree RENAME TO uploadtree_a');
263 $this->testDb->insertData(array(
'uploadtree_a',
'pfile'));
265 $hashes = $this->treeDao->getItemHashes(463,
'uploadtree_a');
266 assertThat($hashes,equalTo(array(
'md5'=>
'C655F0AD3E4D3F90D8EE0541DD636E2E',
'sha1'=>
'D62DCD25DC68180758FD1C064ADC91AB70A78CB1',
'sha256'=>
'8F39AC8ADD8CD0C0C2BF8924CE3B24F4B2760B8723BFD4205A49FB142490A355')));
269 protected function getNestedTestFileStructure()
285 array(14, 13, 2, 8, 32768, 5, 6,
'someFileInFolder', 13, ),
286 array(13, 5, 2, 0, 536888320, 4, 7,
'someFolder', 5, ),
287 array(12, 11, 2, 7, 33188, 13, 14,
'innerFile', 11, ),
288 array(11, 10, 2, 0, 536888320, 12, 15,
'subExample', 9, ),
289 array(10, 9, 2, 0, 805323776, 11, 16,
'artifact.dir', 9, ),
290 array(9, 8, 2, 6, 536903680, 10, 17,
'subExample.tar', 7, ),
291 array(8, 7, 2, 0, 805323776, 9, 18,
'artifact.dir', 7, ),
292 array(7, 5, 2, 5, 536903680, 8, 19,
'subExample.tar.gz', 5, ),
293 array(6, 5, 2, 4, 32768, 20, 21,
'file', 5, ),
294 array(5, 4, 2, 0, 536888320, 3, 22,
'example', 2, ),
295 array(4, 2, 2, 0, 805323776, 2, 23,
'artifact.dir', 2, ),
296 array(3, 2, 2, 3, 268469248, 24, 25,
'artifact.meta', 2, ),
297 array(2, NULL, 2, 2, 536904704, 1, 26,
'example.zip', NULL, ),
301 public function testGetFullPathWithNestedStructure()
304 assertThat($this->treeDao->getFullPath(2,
"uploadtree", 0), equalTo(
'example.zip'));
305 assertThat($this->treeDao->getFullPath(2,
"uploadtree", 0,
true), equalTo(
'example.zip'));
307 assertThat($this->treeDao->getFullPath(6,
"uploadtree", 0), equalTo(
'example.zip/example/file'));
308 assertThat($this->treeDao->getFullPath(6,
"uploadtree", 0,
true), equalTo(
'example/file'));
310 assertThat($this->treeDao->getFullPath(12,
"uploadtree", 0), equalTo(
'example.zip/example/subExample.tar.gz/subExample.tar/subExample/innerFile'));
311 assertThat($this->treeDao->getFullPath(12,
"uploadtree", 0,
true), equalTo(
'example/subExample.tar.gz/subExample.tar/subExample/innerFile'));
313 assertThat($this->treeDao->getFullPath(12,
"uploadtree", 5), equalTo(
'subExample.tar.gz/subExample.tar/subExample/innerFile'));
314 assertThat($this->treeDao->getFullPath(12,
"uploadtree", 5,
true), equalTo(
'subExample/innerFile'));
316 assertThat($this->treeDao->getFullPath(12,
"uploadtree", 7), equalTo(
'subExample.tar/subExample/innerFile'));
317 assertThat($this->treeDao->getFullPath(12,
"uploadtree", 7,
true), equalTo(
'subExample/innerFile'));
prepareModularTable($subentries=array())
fo_dbManager * dbManager
fo_dbManager object
prepareUploadTree($uploadTreeArray=array())