コード例 #1
0
 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]);
 }
コード例 #2
0
 function it_normalize_products($productNormalizer, $versionNormalizer, $versionManager, $localeManager, ProductInterface $mug, AssociationInterface $upsell, AssociationTypeInterface $groupType, GroupInterface $group, ArrayCollection $groups)
 {
     $productNormalizer->normalize($mug, 'json', [])->willReturn(['normalized_property' => 'a nice normalized property']);
     $mug->getId()->willReturn(12);
     $versionManager->getOldestLogEntry($mug)->willReturn('create_version');
     $versionNormalizer->normalize('create_version', 'internal_api')->willReturn('normalized_create_version');
     $versionManager->getNewestLogEntry($mug)->willReturn('update_version');
     $versionNormalizer->normalize('update_version', 'internal_api')->willReturn('normalized_update_version');
     $localeManager->getActiveCodes()->willReturn(['en_US', 'fr_FR']);
     $mug->getLabel('en_US')->willReturn('A nice Mug!');
     $mug->getLabel('fr_FR')->willReturn('Un très beau Mug !');
     $mug->getAssociations()->willReturn([$upsell]);
     $upsell->getAssociationType()->willReturn($groupType);
     $groupType->getCode()->willReturn('group');
     $upsell->getGroups()->willReturn($groups);
     $groups->toArray()->willReturn([$group]);
     $group->getId()->willReturn(12);
     $this->normalize($mug, 'internal_api', [])->shouldReturn(['normalized_property' => 'a nice normalized property', 'meta' => ['id' => 12, 'created' => 'normalized_create_version', 'updated' => 'normalized_update_version', 'label' => ['en_US' => 'A nice Mug!', 'fr_FR' => 'Un très beau Mug !'], 'associations' => ['group' => ['groupIds' => [12]]]]]);
 }