function it_updates_a_association_type(AssociationTypeInterface $associationType, AssociationTypeTranslation $translatable)
 {
     $associationType->getTranslation()->willReturn($translatable);
     $translatable->setLabel('Vente croisée')->shouldBeCalled();
     $associationType->setCode('mycode')->shouldBeCalled();
     $associationType->setLocale('fr_FR')->shouldBeCalled();
     $associationType->getId()->willReturn(null);
     $values = ['code' => 'mycode', 'labels' => ['fr_FR' => 'Vente croisée']];
     $this->update($associationType, $values, []);
 }
 function it_normalizes_an_association_with_products_and_groups($mongoFactory, Association $assoc, AssociationTypeInterface $assocType, \MongoId $mongoId, \MongoDBRef $ownerRef, ProductInterface $product1, \MongoDBRef $product1Ref, ProductInterface $product2, \MongoDBRef $product2Ref, GroupInterface $group1, GroupInterface $group2)
 {
     $assocType->getId()->willReturn(8);
     $assoc->getAssociationType()->willReturn($assocType);
     $context = ['_id' => '1234abc', 'collection_name' => 'product'];
     $mongoFactory->createMongoId()->willReturn($mongoId);
     $mongoFactory->createMongoDBRef('product', '1234abc')->willReturn($ownerRef);
     $mongoFactory->createMongoDBRef('product', 'product1')->willReturn($product1Ref);
     $mongoFactory->createMongoDBRef('product', 'product2')->willReturn($product2Ref);
     $product1->getId()->willReturn('product1');
     $product2->getId()->willReturn('product2');
     $assoc->getProducts()->willReturn([$product1, $product2]);
     $group1->getId()->willReturn(1);
     $group2->getId()->willReturn(2);
     $assoc->getGroups()->willReturn([$group1, $group2]);
     $this->normalize($assoc, 'mongodb_document', $context)->shouldReturn(['_id' => $mongoId, 'associationType' => 8, 'owner' => $ownerRef, 'products' => [$product1Ref, $product2Ref], 'groupIds' => [1, 2]]);
 }
 /**
  * {@inheritdoc}
  */
 public function countForAssociationType(AssociationTypeInterface $associationType)
 {
     $assocMatch = ['$and' => [['associationType' => $associationType->getId()], ['$or' => [['products' => ['$ne' => []]], ['groups' => ['$ne' => []]]]]]];
     $qb = $this->createQueryBuilder()->hydrate(false)->field('associations')->elemMatch($assocMatch)->select('_id');
     return $qb->getQuery()->execute()->count();
 }
 /**
  * @param AssociationTypeInterface $associationType
  *
  * @Given /^I should be on the ("([^"]*)" association type) page$/
  */
 public function iShouldBeOnTheAssociationTypePage(AssociationTypeInterface $associationType)
 {
     $expectedAddress = $this->getPage('AssociationType edit')->getUrl(['id' => $associationType->getId()]);
     $this->assertAddress($expectedAddress);
 }