public function it_succesfully_checks_incomplete_attribute(ProductValueInterface $value, ChannelInterface $channel, LocaleInterface $locale, ProductValueCompleteCheckerInterface $completenessChecker, AttributeInterface $attribute)
 {
     $completenessChecker->supportsValue($value)->willReturn(true);
     $completenessChecker->isComplete($value, $channel, $locale)->willReturn(false);
     $this->addProductValueChecker($completenessChecker);
     $value->getAttribute()->willReturn($attribute);
     $value->getData()->willReturn('foo');
     $this->isComplete($value, $channel, $locale)->shouldReturn(false);
 }
 /**
  * Adds a requirement to the completenesses
  *
  * @param array                         &$completenesses
  * @param AttributeRequirementInterface $requirement
  * @param ArrayCollection               $productValues
  * @param LocaleInterface[]             $locales
  */
 protected function addRequirementToCompleteness(array &$completenesses, AttributeRequirementInterface $requirement, ArrayCollection $productValues, array $locales)
 {
     $attribute = $requirement->getAttribute();
     $channel = $requirement->getChannel();
     foreach ($locales as $locale) {
         $localeCode = $locale->getCode();
         $valueCode = $this->getValueCode($attribute, $localeCode, $channel->getCode());
         $productValue = isset($productValues[$valueCode]) ? $productValues[$valueCode] : null;
         $isIncomplete = null !== $productValue && $this->valueCompleteChecker->supportsValue($productValue) && !$this->valueCompleteChecker->isComplete($productValue, $channel, $locale);
         $shouldExistInLocale = !$attribute->isLocaleSpecific() || $attribute->hasLocaleSpecific($locale);
         if ((null === $productValue || $isIncomplete) && $shouldExistInLocale) {
             $completenesses[$localeCode]['channels'][$channel->getCode()]['missing'][] = $attribute;
         }
     }
 }
 /**
  * Adds a requirement to the completenesses
  *
  * @param array                         &$completenesses
  * @param AttributeRequirementInterface $requirement
  * @param ArrayCollection               $productValues
  * @param Locale[]                      $locales
  */
 protected function addRequirementToCompleteness(array &$completenesses, AttributeRequirementInterface $requirement, ArrayCollection $productValues, array $locales)
 {
     $attribute = $requirement->getAttribute();
     $channel = $requirement->getChannel();
     foreach ($locales as $locale) {
         $localeCode = $locale->getCode();
         $valueCode = $this->getValueCode($attribute, $localeCode, $channel->getCode());
         $missing = false;
         $productValue = isset($productValues[$valueCode]) ? $productValues[$valueCode] : null;
         if (null === $productValue) {
             $missing = true;
         } elseif ($this->productValueCompleteCkecker->supportsValue($productValue) && !$this->productValueCompleteCkecker->isComplete($productValue, $channel, $locale)) {
             $missing = true;
         }
         if ($missing) {
             $completenesses[$localeCode]['channels'][$channel->getCode()]['missing'][] = $attribute;
         }
     }
 }