function it_does_not_add_value_if_already_present(ProductValueInterface $notPresent, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $present, ProductInterface $anotherProduct)
 {
     $notPresent->getProduct()->willReturn($product);
     $notPresent->getData()->willReturn('new-data');
     $notPresent->getAttribute()->willReturn($attribute);
     $notPresent->getLocale()->willReturn(null);
     $notPresent->getScope()->willReturn(null);
     $attribute->getCode()->willReturn('sku');
     $this->addValue($notPresent)->shouldReturn(true);
     $present->getProduct()->willReturn($anotherProduct);
     $present->getData()->willReturn('new-data');
     $present->getAttribute()->willReturn($attribute);
     $present->getLocale()->willReturn(null);
     $present->getScope()->willReturn(null);
     $attribute->getCode()->willReturn('sku');
     $this->addValue($present)->shouldReturn(false);
 }
 /**
  * Return true if value has been added, else if value already exists inside the set
  *
  * @param ProductValueInterface $productValue
  *
  * @return bool
  */
 public function addValue(ProductValueInterface $productValue)
 {
     $product = $productValue->getProduct();
     $productIdentifier = $this->getProductIdentifier($product);
     $productValueData = $this->getValueData($productValue);
     $uniqueValueCode = $this->getUniqueValueCode($productValue);
     if (isset($this->uniqueValues[$uniqueValueCode][$productValueData])) {
         $storedIdentifier = $this->uniqueValues[$uniqueValueCode][$productValueData];
         if ($storedIdentifier !== $productIdentifier) {
             return false;
         }
     }
     if (!isset($this->uniqueValues[$uniqueValueCode])) {
         $this->uniqueValues[$uniqueValueCode] = [];
     }
     if (!isset($this->uniqueValues[$uniqueValueCode][$productValueData])) {
         $this->uniqueValues[$uniqueValueCode][$productValueData] = $productIdentifier;
     }
     return true;
 }
 /**
  * Checks if the same exact value has already been processed on a different product instance
  *
  * When validates values for a VariantGroup there is not product related to the value
  *
  * @param ProductValueInterface $productValue
  *
  * @return bool
  */
 protected function hasAlreadyValidatedTheSameValue(ProductValueInterface $productValue)
 {
     if (null !== $productValue->getProduct()) {
         return false === $this->uniqueValuesSet->addValue($productValue);
     }
     return false;
 }