コード例 #1
0
 public function testMarkAsStartedFunctionality()
 {
     $op1 = new GenericOperation(1);
     $op2 = new GenericOperation(2);
     $op3 = new GenericOperation(3);
     $op4 = new GenericOperation(4);
     $dm = new DependencyManager();
     $dm->addOperation($op1);
     $dm->addOperation($op2);
     $dm->addOperation($op3);
     $dm->addOperation($op4);
     //      1
     //    /  \
     //   2    3
     //    \  /
     //     4
     $dm->addDependencyByOperation($op1, $op2);
     $dm->addDependencyByOperation($op1, $op3);
     $dm->addDependencyByOperation($op2, $op4);
     $dm->addDependencyByOperation($op3, $op4);
     $ops = $dm->getExecutableOperations();
     $this->assertCount(1, $ops);
     $this->assertContains($op1, $ops);
     $dm->markAsStarted($op1);
     $ops = $dm->getExecutableOperations();
     $this->assertCount(0, $ops);
     $dm->markAsExecuted($op1);
     $ops = $dm->getExecutableOperations();
     $this->assertCount(2, $ops);
     $this->assertContains($op2, $ops);
     $this->assertContains($op3, $ops);
     $dm->markAsStarted($op2);
     $ops = $dm->getExecutableOperations();
     $this->assertCount(1, $ops);
     $this->assertContains($op3, $ops);
 }