/**
  * Test getter/setter for id property
  */
 public function testId()
 {
     $this->assertEmpty($this->associationType->getId());
     $newId = 100;
     $this->associationType->setId($newId);
     $this->assertSame($newId, $this->associationType->getId());
 }
 function it_normalizes_an_association_with_products_and_groups($mongoFactory, Association $assoc, AssociationType $assocType, \MongoId $mongoId, \MongoDBRef $ownerRef, ProductInterface $product1, \MongoDBRef $product1Ref, ProductInterface $product2, \MongoDBRef $product2Ref, Group $group1, Group $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]]);
 }
 /**
  * @param AssociationType $associationType
  *
  * @Given /^I should be on the ("([^"]*)" association type) page$/
  */
 public function iShouldBeOnTheAssociationTypePage(AssociationType $associationType)
 {
     $expectedAddress = $this->getPage('AssociationType edit')->getUrl(array('id' => $associationType->getId()));
     $this->assertAddress($expectedAddress);
 }
 /**
  * {@inheritDoc}
  */
 public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) parent::getId();
     }
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array());
     return parent::getId();
 }
 /**
  * {@inheritdoc}
  */
 public function countForAssociationType(AssociationType $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();
 }