Beispiel #1
0
 public function testIsBlocking()
 {
     $blockingStatus = array('s');
     // blocking status without dependencies
     $ticket = new BaseTicket();
     $ticket->setStatus('s');
     $this->boolean($ticket->isBlocking($blockingStatus))->isFalse();
     // non blocking status without dependencies
     $ticket->setStatus('a');
     $this->boolean($ticket->isBlocking($blockingStatus))->isFalse();
     // non blocking status with one non blocking dependency
     $nonBlocking = new BaseTicket();
     $nonBlocking->setStatus('a')->setBlockedBy(array($ticket));
     $ticket->setBlocking(array($nonBlocking));
     $this->boolean($ticket->isBlocking($blockingStatus))->isFalse();
     // blocking status with one non blocking dependency
     $ticket->setStatus('s');
     $this->boolean($ticket->isBlocking($blockingStatus))->isFalse();
     // blocking status with one blocking dependency
     $blocking = new BaseTicket();
     $blocking->setStatus('s')->setBlockedBy(array($ticket));
     $ticket->setBlocking(array($blocking));
     $this->boolean($ticket->isBlocking($blockingStatus))->isTrue();
     // blocking status with one non blocking dependency and one blocking dependency
     $ticket->setBlocking(array($nonBlocking, $blocking));
     $this->boolean($ticket->isBlocking($blockingStatus))->isTrue();
 }
Beispiel #2
0
 private static function flattenByBlock(Ticket $ticket, array &$flattened)
 {
     if (!isset($flattened[$ticket->getId()])) {
         $flattened[$ticket->getId()] = $ticket;
         foreach ($ticket->getBlocking() as $blocking) {
             self::flattenByBlock($blocking, $flattened);
         }
         foreach ($ticket->getBlockedBy() as $blockedBy) {
             self::flattenByBlock($blockedBy, $flattened);
         }
     }
 }
 public function convertTicketFromApi($ticket)
 {
     if (!$ticket instanceof Ticket) {
         return null;
     }
     $t = new Model\Ticket();
     $t->setRaw($ticket)->setId($ticket->get('id'))->setTitle($ticket->get('summary'))->setDescription($ticket->get('description'))->setStatus($ticket->get('status'))->setReporter($ticket->get('reporter'))->setMilestone($ticket->get('milestone'))->setType($ticket->get('type'))->setOwner($ticket->get('owner'))->setPriority($ticket->get('priority'))->setUrl($ticket->getUrl())->setIsClosed($ticket->get('status') === TracApi::STATUS_CLOSED)->setKeywords(explode(' ', $ticket->get('keywords')))->setProviderSpecific(array('_ts' => $ticket->get('_ts')));
     $blocking = $ticket->get('blocking');
     if (!empty($blocking)) {
         $t->setBlocking(explode(', ', $blocking));
     }
     $blockedBy = $ticket->get('blockedby');
     if (!empty($blockedBy)) {
         $t->setBlockedBy(explode(', ', $blockedBy));
     }
     return $t;
 }
Beispiel #4
0
 public function testSortByBlocking()
 {
     $blockingStatus = array('s');
     $features = array();
     /**
      * 8 blocking 3 and 5
      * 5 blocking 3 and 4
      */
     $t1_3 = new Ticket();
     $t1_3->setId('1_3')->setStatus('s');
     $t1_4 = new Ticket();
     $t1_4->setId('1_4')->setStatus('s');
     $t1_5 = new Ticket();
     $t1_5->setId('1_5')->setStatus('s');
     $t1_8 = new Ticket();
     $t1_8->setId('1_8')->setStatus('a');
     $t1_5->setBlocking(array($t1_3, $t1_4))->setBlockedBy(array($t1_8));
     $t1_8->setBlocking(array($t1_3, $t1_5));
     $t1_3->setBlockedBy(array($t1_5, $t1_8));
     $t1_4->setBlockedBy(array($t1_5));
     $features[] = $feature_1_5 = new Feature($t1_5);
     $features[] = $feature_1_3 = new Feature($t1_3);
     /**
      * 3 blocking 5
      */
     $t2_3 = new Ticket();
     $t2_3->setId('2_3')->setStatus('s');
     $t2_5 = new Ticket();
     $t2_5->setId('2_5')->setStatus('s');
     $t2_3->setBlocking(array($t2_5));
     $t2_5->setBlockedBy(array($t2_3));
     $features[] = $feature_2_5 = new Feature($t2_5);
     $features[] = $feature_2_3 = new Feature($t2_3);
     /**
      * No blocking
      */
     $t3_1 = new Ticket();
     $t3_1->setId('3_1')->setStatus(1);
     $features[] = $feature_3_1 = new Feature($t3_1);
     $sorted = BaseSorter::sortByBlockingTickets($features, $blockingStatus);
     $this->array($sorted)->hasSize(5)->hasKeys(array(0, 1, 2, 3, 4))->object($sorted[0])->isEqualTo($feature_3_1)->object($sorted[1])->isEqualTo($feature_2_3)->object($sorted[2])->isEqualTo($feature_2_5)->object($sorted[3])->isEqualTo($feature_1_5)->object($sorted[4])->isEqualTo($feature_1_3);
 }
Beispiel #5
0
 protected function populateDependencies(Model\Ticket $ticket = null, array &$populated = array())
 {
     if ($ticket) {
         if (!isset($populated[$ticket->getId()])) {
             $populated[$ticket->getId()] = true;
             $blocking = array();
             foreach ($ticket->getBlocking() as $id) {
                 if (is_scalar($id) && !empty($id)) {
                     $blocking[] = $this->getPopulatedDependenciesById($id, $populated);
                 }
             }
             $ticket->setBlocking($blocking);
             $blockedBy = array();
             foreach ($ticket->getBlockedBy() as $id) {
                 if (is_scalar($id) && !empty($id)) {
                     $blockedBy[] = $this->getPopulatedDependenciesById($id, $populated);
                 }
             }
             $ticket->setBlockedBy($blockedBy);
         }
     }
 }
 /**
  * Update a ticket from TicketUpdate data
  *
  * @param \CleverAge\Orchestrator\Ticketing\Model\Ticket $ticket
  * @param \CleverAge\Orchestrator\Ticketing\Model\TicketUpdate $update
  * @return \CleverAge\Orchestrator\Ticketing\Model\Ticket
  */
 public function updateTicket(Model\Ticket $ticket, Model\TicketUpdate $update)
 {
     return $this->getResource('doUpdateTicket', func_get_args(), array('cache_key' => 'ticket_' . $ticket->getId(), 'cache_lifetime' => $this->cacheLifetime['ticket'], 'cache_no_get' => true));
 }