コード例 #1
0
ファイル: Scheduler.php プロジェクト: bravo3/workflow
 /**
  * Check if we meet all reason requirements
  *
  * @param array $requirements
  * @return bool
  */
 protected function meetsControlRequirements(array $requirements)
 {
     foreach ($requirements as $control => $count) {
         if ($this->history_inspector->countControl($control, HistoryItemState::COMPLETED()) != $count) {
             return false;
         }
     }
     return true;
 }
コード例 #2
0
 public function testCounts()
 {
     $history = new WorkflowHistory();
     $history->add($this->createHistoryItem('test-activity', '1', HistoryItemState::COMPLETED(), 'alpha'));
     $history->add($this->createHistoryItem('test-activity', '1', HistoryItemState::COMPLETED(), 'bravo'));
     $history->add($this->createHistoryItem('test-activity', '2', HistoryItemState::COMPLETED(), 'charlie'));
     $history->add($this->createHistoryItem('test-activity', '1', HistoryItemState::SCHEDULED(), 'delta'));
     $history->add($this->createHistoryItem('other-activity', '1', HistoryItemState::COMPLETED(), 'echo'));
     $history->add($this->createHistoryItem('other-activity', '1', HistoryItemState::RUNNING(), 'foxtrot'));
     $inspector = new HistoryInspector($history);
     $schema_test = TaskSchema::fromKey('test-activity/1');
     $schema_other = TaskSchema::fromKey('other-activity/1');
     $this->assertEquals(0, $inspector->countTask($schema_test, HistoryItemState::RUNNING()));
     $this->assertEquals(0, $inspector->countTask($schema_test, HistoryItemState::FAILED()));
     $this->assertEquals(2, $inspector->countTask($schema_test, HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countTask($schema_test, HistoryItemState::SCHEDULED()));
     $this->assertEquals(1, $inspector->countTask($schema_other, HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countTask($schema_other, HistoryItemState::RUNNING()));
     $this->assertEquals(0, $inspector->countTask($schema_other, HistoryItemState::SCHEDULED()));
     $this->assertEquals(0, $inspector->countTask($schema_other, HistoryItemState::FAILED()));
     $this->assertEquals(1, $inspector->countControl('alpha', HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countControl('bravo', HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countControl('charlie', HistoryItemState::COMPLETED()));
     $this->assertEquals(0, $inspector->countControl('delta', HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countControl('echo', HistoryItemState::COMPLETED()));
     $this->assertEquals(0, $inspector->countControl('foxtrot', HistoryItemState::COMPLETED()));
     $this->assertTrue($inspector->haveOpenActivities());
     $alpha = new TaskSchema();
     $alpha->setActivityName('test-activity')->setActivityVersion('1')->setControl('alpha');
     $this->assertEquals(2, $inspector->countTask($alpha, HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countTask($alpha, HistoryItemState::SCHEDULED()));
     $omega = new TaskSchema();
     $omega->setActivityName('test-activity')->setActivityVersion('10');
     $this->assertEquals(0, $inspector->countTask($omega, HistoryItemState::COMPLETED()));
     $this->assertTrue($inspector->hasTaskBeenScheduled($alpha));
     $this->assertFalse($inspector->hasTaskBeenScheduled($omega));
 }