/**
  * @expectedException \LogicException
  * @expectedExceptionMessage Several related attribute options found by the same locale ID.
  */
 public function testGetRelatedOptionByLocaleIdException()
 {
     $locale = $this->createLocale(1);
     $firstOption = new AttributeOption();
     $firstOption->setLocale($locale);
     $secondOption = new AttributeOption();
     $secondOption->setLocale($locale);
     $masterOption = new AttributeOption();
     $masterOption->addRelatedOption($firstOption)->addRelatedOption($secondOption);
     $masterOption->getRelatedOptionByLocaleId(1);
 }
 /**
  * @param AttributeOption $masterOption
  * @param int $localeId
  * @param string|FallbackType $value
  * @param int $order
  * @return null|AttributeOption
  */
 protected function generateOption(AttributeOption $masterOption, $localeId, $value, $order)
 {
     if ($localeId) {
         $option = $masterOption->getRelatedOptionByLocaleId($localeId);
         if (!$option) {
             $option = new AttributeOption();
             $option->setLocale($this->databaseHelper->findLocale($localeId));
             $masterOption->addRelatedOption($option);
         }
     } else {
         $option = $masterOption;
     }
     if ($value instanceof FallbackType) {
         $option->setFallback($value->getType())->setValue(null);
     } else {
         $option->setFallback(null)->setValue($value);
     }
     $option->setOrder($order);
     return $option;
 }