public function testValid() { $arr = array(); $element = new Xinc_Build(new Xinc_Engine_Sunrise(), new Xinc_Project()); $arr[] = $element; try { $iterator = new Xinc_Build_Iterator($arr); $hasNext = $iterator->hasNext(); $this->assertTrue($hasNext, 'Should be true'); $count = $iterator->count(); $this->assertEquals($count, 1, 'Should have 1 entry but has: ' . $count); $next = $iterator->next(); $this->assertEquals($element, $next, 'Elements should be equal'); $iterator->rewind(); $hasNext = $iterator->hasNext(); $this->assertTrue($hasNext, 'Should be true'); $count = $iterator->count(); $this->assertEquals($count, 1, 'Should have 1 entry but has: ' . $count); $next = $iterator->next(); } catch (Xinc_Build_Exception_Invalid $invalid) { $this->assertTrue(false, 'Expected result'); } catch (Exception $e) { $this->assertTrue(false, 'Not expected'); } }
protected function _generateChildren() { $builds = new Xinc_Build_Iterator(); $handler = Xinc_Gui_Handler::getInstance(); $statusDir = $handler->getStatusDir(); $dir = opendir($statusDir); while ($file = readdir($dir)) { $fullfile = $statusDir . DIRECTORY_SEPARATOR . $file; if (!in_array($file, array('.', '..')) && is_dir($fullfile)) { $statusfile = $fullfile . DIRECTORY_SEPARATOR . 'build.ser'; if (file_exists($statusfile)) { $project = new Xinc_Project(); $project->setName($file); try { $object = Xinc_Build_Repository::getLastBuild($project); $builds->add($object); } catch (Exception $e) { } } } } $projects = array(); while ($builds->hasNext()) { $build = $builds->next(); /** * Do we have children? */ $children = array(); foreach ($this->_subMenus as $subExtension) { $item = $subExtension->getItem($build->getProject()); if (!$item instanceof Xinc_Plugin_Repos_Gui_Menu_Extension_Item) { continue; } $children[] = $item->generate(); } $item = new Xinc_Plugin_Repos_Gui_Menu_Extension_Item('project-' . $build->getProject()->getName() . '-' . $build->getBuildTime(), $build->getLabel() . ' - ' . $build->getProject()->getName(), './dashboard/detail?project=' . $build->getProject()->getName() . '×tamp=' . $build->getBuildTime(), $build->getProject()->getName(), '', false, count($children) > 0 ? false : true, $children); $projects[] = $item->generate(); } return implode(',', $projects); }
/** * Returns the next build time of all the builds scheduled * in this queue * * @return integer unixtimestamp */ public function getNextBuildTime() { $nextBuildTime = null; /** * Xinc_Build_Interface */ $build = null; while ($this->builds->hasNext()) { $build = $this->builds->next(); $this->_handleBuildConfig($build); $buildTime = $build->getNextBuildTime(); if ($buildTime <= $nextBuildTime || $nextBuildTime === null) { if ($build->getStatus() != Xinc_Build_Interface::STOPPED) { if ($buildTime !== null) { $this->addBuild2Queue($build); } $nextBuildTime = $buildTime; } } } $this->builds->rewind(); return $nextBuildTime; }