コード例 #1
0
ファイル: Resource.php プロジェクト: sirdiego/importr
 /**
  * @param ResourceInterface $resource
  * @param int $pointer
  * @param array $targets
  * @param Import $import
  */
 protected function processOneLine(ResourceInterface $resource, $pointer, array $targets, Import $import)
 {
     $entry = $resource->getEntry($pointer);
     foreach ($targets as $target) {
         $this->target->process($target, $entry, $import, $pointer);
     }
 }
コード例 #2
0
ファイル: TargetTest.php プロジェクト: sirdiego/importr
 /**
  * @test
  * @expectedException \Exception
  */
 public function processWithException()
 {
     $entry = [];
     /** @var \PHPUnit_Framework_MockObject_MockObject|TargetInterface $target */
     $target = $this->getMockBuilder(TargetInterface::class)->getMock();
     $target->expects($this->once())->method('processEntry')->with($this->equalTo($entry))->will($this->throwException(new \Exception()));
     $target->expects($this->any())->method('getConfiguration')->will($this->returnValue([]));
     /** @var \PHPUnit_Framework_MockObject_MockObject|Import $import */
     $import = $this->getMockBuilder(Import::class)->getMock();
     $import->expects($this->once())->method('increaseCount')->with($this->equalTo(TargetInterface::RESULT_ERROR));
     $pointer = 1;
     $this->fixture->process($target, $entry, $import, $pointer);
 }
コード例 #3
0
ファイル: ResourceTest.php プロジェクト: sirdiego/importr
 /**
  * @test
  */
 public function calls_target_processor()
 {
     $this->target->expects($this->once())->method('process');
     $import = $this->getMock(Import::class);
     $import->expects($this->once())->method('getFilepath')->will($this->returnValue('./import.csv'));
     $import->expects($this->once())->method('getPointer')->will($this->returnValue(0));
     $import->expects($this->exactly(2))->method('getAmount')->will($this->returnValue(1));
     $resource = $this->getMock(ResourceInterface::class);
     $resource->expects($this->once())->method('getFilepathExpression')->will($this->returnValue('/\\.csv$/'));
     $manager = $this->getMock(ManagerInterface::class);
     $manager->expects($this->any())->method('getUpdateInterval')->will($this->returnValue(42));
     $target = $this->getMock(TargetInterface::class);
     $result = $this->fixture->process($import, [$target], [], $resource, $manager);
 }