Skip to content

Commit

Permalink
DoctrineWrite fix for issue ddeboer#194
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantus committed Apr 30, 2015
1 parent 45069d8 commit 10e2409
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Ddeboer/DataImport/Writer/DoctrineWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ class DoctrineWriter extends AbstractWriter
public function __construct(EntityManagerInterface $entityManager, $entityName, $index = null)
{
$this->entityManager = $entityManager;
$this->entityName = $entityName;
$this->entityRepository = $entityManager->getRepository($entityName);
$this->entityMetadata = $entityManager->getClassMetadata($entityName);
//translate entityName in case a namespace alias is used
$this->entityName = $this->entityMetadata->getName();
if($index) {
if(is_array($index)) {
$this->lookupFields = $index;
Expand Down
15 changes: 15 additions & 0 deletions tests/Ddeboer/DataImport/Tests/Writer/DoctrineWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,19 @@ public function testLoadAssociationWithPresetObject()

$writer->writeItem($item);
}

/**
* Test to make sure that we are clearing the write entity
*/
public function testFlushAndClear()
{
$em = $this->getEntityManager();

$em->expects($this->once())
->method('clear')
->with($this->equalTo('Ddeboer\DataImport\Tests\Fixtures\Entity\TestEntity'));

$writer = new DoctrineWriter($em, 'DdeboerDataImport:TestEntity');
$writer->finish();
}
}

0 comments on commit 10e2409

Please sign in to comment.