Пример #1
0
 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');
     }
 }
Пример #2
0
 /**
  * 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;
 }