Exemplo n.º 1
0
 public function testClassResolvedOnce()
 {
     /** @var StepExecution $stepExecution */
     $stepExecution = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Entity\\StepExecution')->disableOriginalConstructor()->getMock();
     $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
     $context->expects($this->once())->method('getConfiguration')->will($this->returnValue(['entityName' => '\\stdClass']));
     $this->contextRegistry->expects($this->once())->method('getByStepExecution')->with($stepExecution)->will($this->returnValue($context));
     $this->writer->setStepExecution($stepExecution);
     $this->writer->write([]);
     // trigger detection twice
     $this->writer->write([]);
 }
 public function testWrite()
 {
     $fooItem = $this->getMock('FooItem');
     $barItem = $this->getMock('BarItem');
     $this->detachFixer->expects($this->at(0))->method('fixEntityAssociationFields')->with($fooItem, 1);
     $this->detachFixer->expects($this->at(1))->method('fixEntityAssociationFields')->with($barItem, 1);
     $this->entityManager->expects($this->at(0))->method('persist')->with($fooItem);
     $this->entityManager->expects($this->at(1))->method('persist')->with($barItem);
     $this->entityManager->expects($this->at(2))->method('flush');
     $items = array($fooItem, $barItem);
     $this->writer->write($items);
 }
Exemplo n.º 3
0
 /**
  * @param array $configuration
  *
  * @dataProvider configurationProvider
  */
 public function testWrite($configuration)
 {
     $fooItem = $this->getMock('FooItem');
     $barItem = $this->getMock('BarItem');
     $this->detachFixer->expects($this->at(0))->method('fixEntityAssociationFields')->with($fooItem, 1);
     $this->detachFixer->expects($this->at(1))->method('fixEntityAssociationFields')->with($barItem, 1);
     $this->entityManager->expects($this->at(0))->method('persist')->with($fooItem);
     $this->entityManager->expects($this->at(1))->method('persist')->with($barItem);
     $this->entityManager->expects($this->at(2))->method('flush');
     $stepExecution = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Entity\\StepExecution')->disableOriginalConstructor()->getMock();
     $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
     $context->expects($this->once())->method('getConfiguration')->will($this->returnValue($configuration));
     $this->contextRegistry->expects($this->once())->method('getByStepExecution')->with($stepExecution)->will($this->returnValue($context));
     if (empty($configuration[EntityWriter::SKIP_CLEAR])) {
         $this->entityManager->expects($this->at(3))->method('clear');
     }
     $this->writer->setStepExecution($stepExecution);
     $this->writer->write([$fooItem, $barItem]);
 }