/**
  * @param ItemTreeBounds $itemTreeBounds
  * @return array with keys 'isFlat','iTotalRecords','fileSwitch'
  */
 private function countFileListing(ItemTreeBounds $itemTreeBounds)
 {
     $isFlat = isset($_GET['flatten']);
     $vars['isFlat'] = $isFlat;
     $vars['iTotalRecords'] = $this->uploadDao->countNonArtifactDescendants($itemTreeBounds, $isFlat);
     $uri = Traceback_uri() . '?mod=' . $this->Name . Traceback_parm_keep(array('upload', 'folder', 'show', 'item'));
     $vars['fileSwitch'] = $isFlat ? $uri : $uri . "&flatten=yes";
     return $vars;
 }
 public function testCountNonArtifactDescendants()
 {
     $this->dbManager->queryOnce('ALTER TABLE uploadtree RENAME TO uploadtree_a');
     $this->testDb->insertData(array('uploadtree_a'));
     $artifact = new ItemTreeBounds(2, 'uploadtree_a', 1, 2, 3);
     $artifactDescendants = $this->uploadDao->countNonArtifactDescendants($artifact);
     assertThat($artifactDescendants, is(0));
     $zip = new ItemTreeBounds(1, 'uploadtree_a', 1, 1, 24);
     $zipDescendants = $this->uploadDao->countNonArtifactDescendants($zip);
     assertThat($zipDescendants, is(count(array(6, 7, 8, 10, 11, 12))));
 }