/**
  * Test for __toString method
  */
 public function testToString()
 {
     // Change value and assert new
     $newCode = 'toStringCode';
     $expectedCode = '[' . $newCode . ']';
     $this->associationType->setCode($newCode);
     $this->assertEquals($expectedCode, $this->associationType->__toString());
     $newLabel = 'toStringLabel';
     $this->assertEntity($this->associationType->setLocale('en_US'));
     $this->assertEntity($this->associationType->setLabel($newLabel));
     $this->assertEquals($newLabel, $this->associationType->__toString());
     // if no translation, assert the expected code is returned
     $this->associationType->setLocale('fr_FR');
     $this->assertEquals($expectedCode, $this->associationType->__toString());
     // if empty translation, assert the expected code is returned
     $this->associationType->setLabel('');
     $this->assertEquals($expectedCode, $this->associationType->__toString());
 }
 /**
  * {@inheritdoc}
  * @return AssociationTypeInterface
  */
 protected function createEntity(array $data)
 {
     $associationType = new AssociationType();
     $associationType->setCode($data['code']);
     foreach ($this->getLabels($data) as $locale => $label) {
         $translation = $associationType->getTranslation($locale);
         $translation->setLabel($label);
         $associationType->addTranslation($translation);
     }
     return $associationType;
 }
Пример #3
0
 /**
  * @param string $code
  * @param string $label
  */
 protected function createAssociationType($code, $label)
 {
     $associationType = new AssociationType();
     $associationType->setCode($code);
     $associationType->setLocale('en_US')->setLabel($label);
     $this->validate($associationType);
     $this->persist($associationType);
 }
 /**
  * {@inheritDoc}
  */
 public function setCode($code)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCode', array($code));
     return parent::setCode($code);
 }
Пример #5
0
 /**
  * @param string $code
  * @param string $label
  */
 protected function createAssociationType($code, $label)
 {
     $associationType = new AssociationType();
     $associationType->setCode($code);
     $associationType->setLocale('en_US')->setLabel($label);
     $this->validate($associationType);
     $this->getContainer()->get('pim_catalog.saver.association_type')->save($associationType);
 }