Example #1
0
 /**
  * Tests getTargets method.
  */
 public function testGetTargets()
 {
     $pb = new ProcedureBuilder();
     $adapter = $this->getMock('Transfer\\Adapter\\TargetAdapterInterface');
     $pb->addTarget($adapter)->createProcedure('procedure_1')->addTarget($adapter)->end();
     $procedure = $pb->getProcedure();
     $children = $procedure->getChildren();
     /** @var Procedure $child */
     foreach ($children as $child) {
         $targets = $child->getTargets();
         $this->assertCount(2, $targets);
     }
 }
Example #2
0
 /**
  * Tests insertion of callable components (sources, workers and targets).
  */
 public function testAddCallableComponent()
 {
     $pb = new ProcedureBuilder();
     $pb->addSource(function (Request $request) {
         return new Response();
     });
     $pb->addWorker(function (ObjectInterface $object) {
     });
     $pb->addTarget(function (Request $request) {
         return new Response();
     });
     $procedure = $pb->getProcedure();
     $sources = $procedure->getSources();
     $workers = $procedure->getWorkers();
     $targets = $procedure->getTargets();
     $this->assertCount(1, $sources);
     $this->assertInstanceOf('Transfer\\Adapter\\CallbackAdapter', $sources[0][0]);
     $this->assertCount(1, $workers);
     $this->assertInstanceOf('Transfer\\Worker\\WorkerInterface', $workers[0]);
     $this->assertCount(1, $targets);
     $this->assertInstanceOf('Transfer\\Adapter\\CallbackAdapter', $targets[0]);
 }