/**
  * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
  */
 public function testUpdateConfigurableProductLinks()
 {
     $productId1 = 10;
     $productId2 = 20;
     $response = $this->createConfigurableProduct();
     $options = $response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]['configurable_product_options'];
     //leave existing option untouched
     unset($response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]['configurable_product_options']);
     $response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]['configurable_product_links'] = [$productId1];
     $response = $this->saveProduct($response);
     $this->assertTrue(isset($response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]["configurable_product_options"]));
     $resultConfigurableProductOptions = $response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]["configurable_product_options"];
     $this->assertEquals(1, count($resultConfigurableProductOptions));
     //Since one product is removed, the available values for the option is reduced
     $this->assertEquals(1, count($resultConfigurableProductOptions[0]['values']));
     $this->assertTrue(isset($response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]["configurable_product_links"]));
     $resultConfigurableProductLinks = $response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]["configurable_product_links"];
     $this->assertEquals(1, count($resultConfigurableProductLinks));
     $this->assertEquals([$productId1], $resultConfigurableProductLinks);
     //adding back the product links, the option value should be restored
     unset($response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]['configurable_product_options']);
     $response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]['configurable_product_links'] = [$productId1, $productId2];
     //set the value for required attribute
     $response["custom_attributes"][] = ["attribute_code" => $this->configurableAttribute->getAttributeCode(), "value" => $resultConfigurableProductOptions[0]['values'][0]['value_index']];
     $response = $this->saveProduct($response);
     $currentOptions = $response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]['configurable_product_options'];
     $this->assertEquals($options, $currentOptions);
 }
 /**
  * Check whether attribute reserved or not
  *
  * @param \Magento\Catalog\Model\Entity\Attribute $attribute
  * @return boolean
  */
 public function isReservedAttribute($attribute)
 {
     return $attribute->getIsUserDefined() && in_array($attribute->getAttributeCode(), $this->_reservedAttributes);
 }