/**
  * Test getter/setter for code property
  */
 public function testGetSetCode()
 {
     $this->assertEmpty($this->channel->getCode());
     // change value and assert new
     $newCode = 'ecommerce';
     $this->assertEntity($this->channel->setCode($newCode));
     $this->assertEquals($newCode, $this->channel->getCode());
 }
 /**
  * {@inheritdoc}
  *
  * @return Family
  */
 protected function createEntity(array $data)
 {
     $family = new Family();
     $family->setCode('mycode');
     foreach ($this->getLabels($data) as $locale => $label) {
         $translation = $family->getTranslation($locale);
         $translation->setLabel($label);
         $family->addTranslation($translation);
     }
     $codes = array('attribute1', 'attribute2', 'attribute3');
     $attributes = array();
     foreach ($codes as $code) {
         $attribute = new Attribute();
         $attribute->setCode($code);
         $family->addAttribute($attribute);
         $attributes[] = $attribute;
     }
     $family->setAttributeAsLabel(current($attributes));
     $channel1 = new Channel();
     $channel1->setCode('channel1');
     $channel2 = new Channel();
     $channel2->setCode('channel2');
     $requirements = array(array('attribute' => $attributes[0], 'channel' => $channel1, 'required' => true), array('attribute' => $attributes[1], 'channel' => $channel1, 'required' => true), array('attribute' => $attributes[2], 'channel' => $channel1, 'required' => false), array('attribute' => $attributes[0], 'channel' => $channel2, 'required' => true), array('attribute' => $attributes[1], 'channel' => $channel2, 'required' => false), array('attribute' => $attributes[2], 'channel' => $channel2, 'required' => true));
     $attrRequirements = array();
     foreach ($requirements as $requirement) {
         $attrRequirement = new AttributeRequirement();
         $attrRequirement->setAttribute($requirement['attribute']);
         $attrRequirement->setChannel($requirement['channel']);
         $attrRequirement->setRequired($requirement['required']);
         $attrRequirements[] = $attrRequirement;
     }
     $family->setAttributeRequirements($attrRequirements);
     return $family;
 }
 /**
  * Create a channel
  * @param string $code
  *
  * @return \Pim\Bundle\CatalogBundle\Entity\Channel
  */
 protected function createChannel($code)
 {
     $channel = new Channel();
     $channel->setCode($code);
     $channel->setLabel(ucfirst($code));
     return $channel;
 }
 /**
  * @return PHPUnit_Framework_MockObject_MockObject
  */
 public function getChannelManagerMock()
 {
     $channel = new Channel();
     $channel->setCode('mobile');
     $mock = $this->getMockBuilder('Pim\\Bundle\\CatalogBundle\\Manager\\ChannelManager')->disableOriginalConstructor()->getMock();
     $mock->expects($this->any())->method('getChannelByCode')->will($this->returnValue($channel));
     return $mock;
 }
 /**
  * {@inheritdoc}
  *
  * @return Channel
  */
 protected function createEntity(array $data)
 {
     $channel = new Channel();
     $channel->setCode($data['code']);
     $channel->setLabel($data['label']);
     foreach ($data['currencies'] as $currencyCode) {
         $currency = $this->createCurrency($currencyCode);
         $channel->addCurrency($currency);
     }
     foreach ($data['locales'] as $localeCode) {
         $locale = $this->createLocale($localeCode);
         $channel->addLocale($locale);
     }
     $category = $this->createCategory($data['category']);
     $channel->setCategory($category);
     $channel->setConversionUnits(array('weight' => 'KILOGRAM', 'washing_temperature' => null));
     return $channel;
 }
 /**
  * @param array $data
  *
  * @return Channel
  */
 protected function createChannel($data)
 {
     if (is_string($data)) {
         $data = [['code' => $data]];
     }
     $data = array_merge(['label' => null, 'color' => null, 'currencies' => null, 'locales' => null, 'tree' => null], $data);
     $channel = new Channel();
     $channel->setCode($data['code']);
     $channel->setLabel($data['label']);
     if ($data['color']) {
         $channel->setColor($data['color']);
     }
     foreach ($this->listToArray($data['currencies']) as $currencyCode) {
         $channel->addCurrency($this->getCurrency($currencyCode));
     }
     foreach ($this->listToArray($data['locales']) as $localeCode) {
         $channel->addLocale($this->getLocale($localeCode));
     }
     if ($data['tree']) {
         $channel->setCategory($this->getCategory($data['tree']));
     }
     $this->validate($channel);
     $this->persist($channel);
 }
 function getChannel()
 {
     $channel = new Channel();
     $channel->setCode('catalog');
     $currency = new Currency();
     $currency->setCode('EUR');
     $channel->addCurrency($currency);
     return $channel;
 }
 /**
  * @return array
  */
 protected function getChannels()
 {
     $codes = array('ecom', 'print');
     $channels = array();
     foreach ($codes as $code) {
         $channel = new Channel();
         $channel->setCode($code);
         foreach ($this->getLocales() as $locale) {
             $channel->addLocale($locale);
         }
         $channels[] = $channel;
     }
     return $channels;
 }
 /**
  * @param array $data
  *
  * @return Channel
  */
 protected function createChannel($data)
 {
     if (is_string($data)) {
         $data = [['code' => $data]];
     }
     $data = array_merge(['label' => null, 'currencies' => null, 'locales' => null, 'tree' => null], $data);
     $channel = new Channel();
     $channel->setCode($data['code']);
     $channel->setLabel($data['label']);
     foreach ($this->listToArray($data['currencies']) as $currencyCode) {
         $channel->addCurrency($this->getCurrency(['code' => explode(',', $currencyCode)]));
     }
     foreach ($this->listToArray($data['locales']) as $localeCode) {
         $channel->addLocale($this->getLocale(['code' => explode(',', $localeCode)]));
     }
     if ($data['tree']) {
         $channel->setCategory($this->getCategory($data['tree']));
     }
     $this->validate($channel);
     $this->getContainer()->get('pim_catalog.saver.channel')->save($channel);
 }
 /**
  * {@inheritDoc}
  */
 public function setCode($code)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCode', array($code));
     return parent::setCode($code);
 }