/** * 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()); }
/** * @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 setLocale($locale) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLocale', array($locale)); return parent::setLocale($locale); }
/** * @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); }