/**
  * Test getter/setter for translations property
  */
 public function testTranslations()
 {
     $this->assertCount(0, $this->category->getTranslations());
     // Change value and assert new
     $newTranslation = $this->createCategoryTranslation();
     $this->assertEntity($this->category->addTranslation($newTranslation));
     $this->assertCount(1, $this->category->getTranslations());
     $this->assertInstanceOf('Pim\\Bundle\\CatalogBundle\\Entity\\CategoryTranslation', $this->category->getTranslations()->first());
     $this->category->addTranslation($newTranslation);
     $this->assertCount(1, $this->category->getTranslations());
     $this->assertEntity($this->category->removeTranslation($newTranslation));
     $this->assertCount(0, $this->category->getTranslations());
 }
 /**
  * {@inheritdoc}
  *
  * @return Category
  */
 protected function createEntity(array $data)
 {
     $category = new Category();
     $category->setCode($data['code']);
     foreach ($this->getLabels($data) as $locale => $label) {
         $translation = $category->getTranslation($locale);
         $translation->setLabel($label);
         $category->addTranslation($translation);
     }
     if ($data['parent']) {
         $parent = new Category();
         $parent->setCode($data['parent']);
         $category->setParent($parent);
     }
     return $category;
 }
 /**
  * {@inheritDoc}
  */
 public function addTranslation(\Pim\Bundle\TranslationBundle\Entity\AbstractTranslation $translation)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addTranslation', array($translation));
     return parent::addTranslation($translation);
 }