/** * Test for __toString method */ public function testToString() { // Change value and assert new $newCode = 'toStringCode'; $expectedCode = '[' . $newCode . ']'; $this->group->setCode($newCode); $this->assertEquals($expectedCode, $this->group->__toString()); $newLabel = 'toStringLabel'; $this->assertEntity($this->group->setLocale('en_US')); $this->assertEntity($this->group->setLabel($newLabel)); $this->assertEquals($newLabel, $this->group->__toString()); // if no translation, assert the expected code is returned $this->group->setLocale('fr_FR'); $this->assertEquals($expectedCode, $this->group->__toString()); // if empty translation, assert the expected code is returned $this->group->setLabel(''); $this->assertEquals($expectedCode, $this->group->__toString()); }
/** * @param string $code * @param string $label * @param string $type * @param array $attributes * @param array $products */ protected function createProductGroup($code, $label, $type, array $attributes, array $products = []) { $group = new Group(); $group->setCode($code); $group->setLocale('en_US')->setLabel($label); // TODO translation refactoring $type = $this->getGroupType($type); $group->setType($type); foreach ($attributes as $attributeCode) { $attribute = $this->getAttribute($attributeCode); $group->addAttribute($attribute); } // TODO replace by call to a saver $this->validate($group); $this->persist($group); $this->flush($group); foreach ($products as $sku) { if (!empty($sku)) { $product = $this->getProduct($sku); $product->addGroup($group); $this->validate($product); $this->getProductSaver()->save($product); } } }
/** * {@inheritDoc} */ public function setLocale($locale) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLocale', array($locale)); return parent::setLocale($locale); }