public function testLoadAssociationWithPresetObject() { $em = $this->getEntityManager(); $em->expects($this->once())->method('persist'); $em->expects($this->never())->method('getReference'); $writer = new DoctrineWriter($em, 'DdeboerDataImport:TestEntity'); $association = new TestEntity(); $item = array('firstProperty' => 'some value', 'secondProperty' => 'some other value', 'firstAssociation' => $association); $writer->writeItem($item); }
public function testBatches() { $em = $this->getEntityManager(); $em->expects($this->exactly(11))->method('persist'); $em->expects($this->exactly(4))->method('flush'); $writer = new DoctrineWriter($em, 'DdeboerDataImport:TestEntity'); $writer->prepare(); $writer->setBatchSize(3); $this->assertEquals(3, $writer->getBatchSize()); $association = new TestEntity(); $item = array('firstProperty' => 'some value', 'secondProperty' => 'some other value', 'firstAssociation' => $association); for ($i = 0; $i < 11; $i++) { $writer->writeItem($item); } $writer->finish(); }