Skip to content

Commit

Permalink
Merge pull request #39 from jean-pasqualini/fix/doctrine-persister
Browse files Browse the repository at this point in the history
fix/doctrine-persister: passer au persister la liste des entité à clear
  • Loading branch information
jean-pasqualini committed Jul 24, 2018
2 parents 44c4363 + 08f51e0 commit 25d6035
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/ImportBundle/Step/DoctrinePersisterStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@ public function __construct(DoctrinePersister $persister)

public function configureOptionResolver(OptionsResolver $resolver): OptionsResolver
{
$resolver->setRequired(['batch_count', 'whitelist_clear']);
$resolver->setRequired(['batch_count', 'whitelist_clear', 'blacklist_clear']);
$resolver->setDefault('whitelist_clear', []);
$resolver->setDefault('blacklist_clear', []);

return parent::configureOptionResolver($resolver);
}

public function execute(ProcessState $state)
{
if (!$state->isDryRun()) {
$this->persister->persist($state->getData(), $state->getOptions()['batch_count']);
$this->persister->persist(
$state->getData(),
$state->getOptions()['batch_count'],
$state->getOptions()['whitelist_clear'],
$state->getOptions()['blacklist_clear']
);

$this->describe($state);
}
Expand Down
8 changes: 6 additions & 2 deletions tests/ImportBundle/Step/DoctrinePersisterStepTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ public function testExecute()
$this->createMock(LoggerInterface::class),
$this->createMock(StepRunner::class)
);
$state->setOptions(['batch_count' => 20]);
$state->setOptions([
'batch_count' => 20,
'whitelist_clear' => [],
'blacklist_clear' => []
]);
$state->setData(new \stdClass());

$this->persister
->expects($this->once())
->method('persist')
->with(new \stdClass());
->with(new \stdClass(), 20, [], []);

$this->step->execute($state);
}
Expand Down

0 comments on commit 25d6035

Please sign in to comment.