function it_massively_insert_and_update_objects($bulkSaver, $bulkDetacher, $stepExecution, ProductInterface $product1, ProductInterface $product2, AssociationInterface $association2) { $bulkSaver->saveAll([$product1, $product2]); $bulkDetacher->detachAll([$product1, $product2]); $product1->getId()->willReturn(null); $association1 = new Association(); $product1->getAssociations()->willReturn(new ArrayCollection([$association1])); $stepExecution->incrementSummaryInfo('process')->shouldBeCalled(); $product2->getId()->willReturn(42); $association2->getId()->willReturn(1); $product2->getAssociations()->willReturn(new ArrayCollection([$association2])); $stepExecution->incrementSummaryInfo('process')->shouldBeCalled(); $this->write([$product1, $product2]); }
function it_saves_associations($registry, AssociationInterface $association1, AssociationInterface $association2, ProductInterface $product1, ProductInterface $product2, GroupInterface $group1, GroupInterface $group2, ObjectManager $manager) { $registry->getManagerForClass(Argument::any())->willReturn($manager); $registry->getManagers()->willReturn([$manager]); $association1->getProducts()->willReturn([$product1, $product2]); $association1->getGroups()->willReturn([$group1, $group2]); $association1->getId()->willReturn(2); $association2->getProducts()->willReturn([$product1, $product2]); $association2->getGroups()->willReturn([$group1, $group2]); $association2->getId()->willReturn(null); $manager->persist($association1)->shouldBeCalled(); $manager->persist($association2)->shouldBeCalled(); $manager->flush()->shouldBeCalled(); $this->write([$association1, $association2]); }