/**
  * Test getter/setter for code property
  */
 public function testGetSetCode()
 {
     $this->assertEmpty($this->associationType->getCode());
     // Change value and assert new
     $newCode = 'test-code';
     $this->assertEntity($this->associationType->setCode($newCode));
     $this->assertEquals($newCode, $this->associationType->getCode());
 }
 function it_gets_association_type_choices_from_repository($entityRepository, AssociationType $associationType)
 {
     $entityRepository->findBy([])->willReturn([$associationType]);
     $associationType->getCode()->willReturn('foo');
     $associationType->getLabel()->willReturn('Foo');
     $this->getAssociationTypeChoices()->shouldReturn(['foo' => 'Foo']);
 }
 function it_returns_association_type_field_names($managerRegistry, AssociationTypeRepository $repository, AssociationType $assocType1, AssociationType $assocType2)
 {
     $assocType1->getCode()->willReturn("ASSOC_TYPE_1");
     $assocType2->getCode()->willReturn("ASSOC_TYPE_2");
     $repository->findAll()->willReturn([$assocType1, $assocType2]);
     $managerRegistry->getRepository(self::ASSOC_TYPE_CLASS)->willReturn($repository);
     $this->getAssociationFieldNames()->shouldReturn(["ASSOC_TYPE_1-groups", "ASSOC_TYPE_1-products", "ASSOC_TYPE_2-groups", "ASSOC_TYPE_2-products"]);
 }
 function it_returns_association_from_an_association_type_code(Association $assoc1, Association $assoc2, AssociationType $assocType1, AssociationType $assocType2)
 {
     $assocType1->getCode()->willReturn('ASSOC_TYPE_1');
     $assocType2->getCode()->willReturn('ASSOC_TYPE_2');
     $assoc1->getAssociationType()->willReturn($assocType1);
     $assoc2->getAssociationType()->willReturn($assocType2);
     $this->setAssociations([$assoc1, $assoc2]);
     $this->getAssociationForTypeCode('ASSOC_TYPE_2')->shouldReturn($assoc2);
 }
 function it_normalizes_product_with_associations($filter, ProductInterface $product, AbstractAttribute $skuAttribute, AbstractProductValue $sku, Association $myCrossSell, AssociationType $crossSell, Association $myUpSell, AssociationType $upSell, Group $associatedGroup1, Group $associatedGroup2, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, AbstractProductValue $skuAssocProduct1, AbstractProductValue $skuAssocProduct2, Collection $values, Family $family, $serializer)
 {
     $family->getCode()->willReturn('shoes');
     $skuAttribute->getCode()->willReturn('sku');
     $skuAttribute->getAttributeType()->willReturn('pim_catalog_identifier');
     $skuAttribute->isLocalizable()->willReturn(false);
     $skuAttribute->isScopable()->willReturn(false);
     $sku->getAttribute()->willReturn($skuAttribute);
     $sku->getData()->willReturn('sku-001');
     $crossSell->getCode()->willReturn('cross_sell');
     $myCrossSell->getAssociationType()->willReturn($crossSell);
     $myCrossSell->getGroups()->willReturn([]);
     $myCrossSell->getProducts()->willReturn([]);
     $upSell->getCode()->willReturn('up_sell');
     $myUpSell->getAssociationType()->willReturn($upSell);
     $associatedGroup1->getCode()->willReturn('associated_group1');
     $associatedGroup2->getCode()->willReturn('associated_group2');
     $myUpSell->getGroups()->willReturn([$associatedGroup1, $associatedGroup2]);
     $skuAssocProduct1->getAttribute()->willReturn($skuAttribute);
     $skuAssocProduct2->getAttribute()->willReturn($skuAttribute);
     $skuAssocProduct1->__toString()->willReturn('sku_assoc_product1');
     $skuAssocProduct2->__toString()->willReturn('sku_assoc_product2');
     $associatedProduct1->getIdentifier()->willReturn($skuAssocProduct1);
     $associatedProduct2->getIdentifier()->willReturn($skuAssocProduct2);
     $myUpSell->getProducts()->willReturn([$associatedProduct1, $associatedProduct2]);
     $product->getIdentifier()->willReturn($sku);
     $product->getFamily()->willReturn($family);
     $product->isEnabled()->willReturn(true);
     $product->getGroupCodes()->willReturn('group1,group2,variant_group_1');
     $product->getCategoryCodes()->willReturn('nice shoes, converse');
     $product->getAssociations()->willReturn([$myCrossSell, $myUpSell]);
     $product->getValues()->willReturn($values);
     $filter->filter(Argument::cetera())->willReturn([$sku]);
     $serializer->normalize($sku, 'flat', Argument::any())->willReturn(['sku' => 'sku-001']);
     $this->normalize($product, 'flat', [])->shouldReturn(['sku' => 'sku-001', 'family' => 'shoes', 'groups' => 'group1,group2,variant_group_1', 'categories' => 'nice shoes, converse', 'cross_sell-groups' => '', 'cross_sell-products' => '', 'up_sell-groups' => 'associated_group1,associated_group2', 'up_sell-products' => 'sku_assoc_product1,sku_assoc_product2', 'enabled' => 1]);
 }
 /**
  * {@inheritDoc}
  */
 public function getCode()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCode', array());
     return parent::getCode();
 }
 /**
  * Get the product association for an Association type
  *
  * @param AssociationType $type
  *
  * @return AbstractAssociation|null
  */
 public function getAssociationForType(AssociationType $type)
 {
     return $this->getAssociationForTypeCode($type->getCode());
 }
 /**
  * {@inheritdoc}
  */
 public function getReference()
 {
     return $this->owner ? $this->owner->getIdentifier() . '.' . $this->associationType->getCode() : null;
 }