/**
  * Delete product attribute step.
  *
  * @return void
  */
 public function run()
 {
     $filter = ['attribute_code' => $this->attribute->getAttributeCode()];
     if ($this->catalogProductAttributeIndex->open()->getGrid()->isRowVisible($filter)) {
         $this->catalogProductAttributeIndex->getGrid()->searchAndOpen($filter);
         $this->catalogProductAttributeNew->getPageActions()->delete();
     }
 }
 /**
  * Delete product attribute step.
  *
  * @return void
  */
 public function run()
 {
     $filter = $this->attribute->hasData('attribute_code') ? ['attribute_code' => $this->attribute->getAttributeCode()] : ['frontend_label' => $this->attribute->getFrontendLabel()];
     $this->catalogProductAttributeIndex->open();
     if ($this->catalogProductAttributeIndex->getGrid()->isRowVisible($filter)) {
         $this->catalogProductAttributeIndex->getGrid()->searchAndOpen($filter);
         $this->catalogProductAttributeNew->getPageActions()->delete();
     }
 }
 /**
  * Run DeleteAssignedToTemplateProductAttribute test
  *
  * @param CatalogAttributeSet $productTemplate
  * @return array
  */
 public function test(CatalogAttributeSet $productTemplate)
 {
     // Precondition
     $productTemplate->persist();
     // Steps
     $filter = ['attribute_code' => $productTemplate->getDataFieldConfig('assigned_attributes')['source']->getAttributes()[0]->getAttributeCode()];
     $this->attributeIndex->open();
     $this->attributeIndex->getGrid()->searchAndOpen($filter);
     $this->attributeNew->getPageActions()->delete();
     return ['productTemplate' => $productTemplate];
 }
 /**
  * Run Delete used in configurable product attribute test
  *
  * @param ConfigurableProduct $product
  * @return array
  */
 public function test(ConfigurableProduct $product)
 {
     // Precondition
     $product->persist();
     /** @var CatalogProductAttribute $attribute */
     $attribute = $product->getDataFieldConfig('configurable_attributes_data')['source']->getAttributes()['attribute_key_0'];
     // Steps
     $this->attributeIndex->open();
     $this->attributeIndex->getGrid()->searchAndOpen(['attribute_code' => $attribute->getAttributeCode()]);
     $this->attributeNew->getPageActions()->delete();
     return ['attribute' => $attribute];
 }
 /**
  * Run test.
  *
  * @param CatalogAttributeSet $attributeSet
  * @return array
  */
 public function test(CatalogAttributeSet $attributeSet)
 {
     // Precondition
     $attributeSet->persist();
     $attribute = $attributeSet->getDataFieldConfig('assigned_attributes')['source']->getAttributes()[0];
     // Steps
     $filter = ['attribute_code' => $attribute->getAttributeCode()];
     $this->attributeIndex->open();
     $this->attributeIndex->getGrid()->searchAndOpen($filter);
     $this->attributeNew->getPageActions()->delete();
     $this->attributeNew->getModalBlock()->acceptAlert();
     return ['attributeSet' => $attributeSet, 'attribute' => $attribute];
 }
 /**
  * Run DeleteProductAttributeEntity test.
  *
  * @param CatalogProductAttribute $attribute
  * @param CatalogProductAttributeIndex $attributeIndex
  * @param CatalogProductAttributeNew $attributeNew
  * @return void
  */
 public function testDeleteProductAttribute(CatalogProductAttribute $attribute, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew)
 {
     //Precondition
     $attribute->persist();
     //Steps
     $attributeIndex->open();
     $attributeIndex->getGrid()->searchAndOpen(['frontend_label' => $attribute->getFrontendLabel()]);
     $attributeNew->getPageActions()->delete();
 }
 /**
  * Run CreateProductAttributeEntity test
  *
  * @param CatalogProductAttribute $productAttribute
  * @param CatalogProductAttributeIndex $attributeIndex
  * @param CatalogProductAttributeNew $attributeNew
  * @param CatalogAttributeSet $productTemplate
  * @return void
  */
 public function testCreateProductAttribute(CatalogProductAttribute $productAttribute, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew, CatalogAttributeSet $productTemplate)
 {
     //Precondition
     $productTemplate->persist();
     //Steps
     $attributeIndex->open();
     $attributeIndex->getPageActionsBlock()->addNew();
     $attributeNew->getAttributeForm()->fill($productAttribute);
     $attributeNew->getPageActions()->save();
 }
 /**
  * Run Delete used in configurable product attribute test
  *
  * @param CatalogProductConfigurable $product
  * @return array
  */
 public function test(CatalogProductConfigurable $product)
 {
     // Precondition
     $product->persist();
     /** @var CatalogProductAttribute $attribute */
     $attribute = $product->getConfigurableAttributesData()['attributes'][0];
     // Steps
     $this->attributeIndex->open();
     $this->attributeIndex->getGrid()->searchAndOpen(['attribute_code' => $attribute->getAttributeCode()]);
     $this->attributeNew->getPageActions()->delete();
     return ['attribute' => $attribute];
 }
 /**
  * Run UpdateProductAttributeEntity test
  *
  * @param CatalogProductAttribute $productAttributeOriginal
  * @param CatalogProductAttribute $attribute
  * @param CatalogAttributeSet $productTemplate
  * @param CatalogProductAttributeIndex $attributeIndex
  * @param CatalogProductAttributeNew $attributeNew
  * @return void
  */
 public function testUpdateProductAttribute(CatalogProductAttribute $productAttributeOriginal, CatalogProductAttribute $attribute, CatalogAttributeSet $productTemplate, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew)
 {
     //Precondition
     $productTemplate->persist();
     $productAttributeOriginal->persist();
     $filter = ['attribute_code' => $productAttributeOriginal->getAttributeCode()];
     //Steps
     $attributeIndex->open();
     $attributeIndex->getGrid()->searchAndOpen($filter);
     $attributeNew->getAttributeForm()->fill($attribute);
     $attributeNew->getPageActions()->save();
 }
 /**
  * Run CreateProductAttributeEntity test
  *
  * @param CatalogProductAttribute $productAttribute
  * @param CatalogProductAttributeIndex $attributeIndex
  * @param CatalogProductAttributeNew $attributeNew
  * @param CatalogAttributeSet $productTemplate
  * @return array
  */
 public function testCreateProductAttribute(CatalogProductAttribute $productAttribute, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew, CatalogAttributeSet $productTemplate)
 {
     $this->markTestIncomplete('MAGETWO-27282');
     //Precondition
     $productTemplate->persist();
     //Steps
     $attributeIndex->open();
     $attributeIndex->getPageActionsBlock()->addNew();
     $attributeNew->getAttributeForm()->fill($productAttribute);
     $attributeNew->getPageActions()->save();
     return ['attribute' => $productAttribute];
 }
 /**
  * Run UpdateProductAttributeEntity test
  *
  * @param CatalogProductAttribute $productAttributeOriginal
  * @param CatalogProductAttribute $attribute
  * @param CatalogAttributeSet $attributeSet
  * @param CatalogProductAttributeIndex $attributeIndex
  * @param CatalogProductAttributeNew $attributeNew
  * @param CatalogProductSimple $productSimple
  * @return array
  */
 public function testUpdateProductAttribute(CatalogProductAttribute $productAttributeOriginal, CatalogProductAttribute $attribute, CatalogAttributeSet $attributeSet, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew, CatalogProductSimple $productSimple)
 {
     //Precondition
     $attributeSet->persist();
     $productAttributeOriginal->persist();
     $filter = ['attribute_code' => $productAttributeOriginal->getAttributeCode()];
     //Steps
     $attributeIndex->open();
     $attributeIndex->getGrid()->searchAndOpen($filter);
     $attributeNew->getAttributeForm()->fill($attribute);
     $attributeNew->getPageActions()->save();
     $attribute = $this->prepareAttribute($attribute, $productAttributeOriginal);
     $productSimple->persist();
     return ['product' => $this->prepareProduct($productSimple, $attribute, $attributeSet)];
 }
 /**
  * Run UpdateProductAttributeEntity test
  *
  * @param CatalogProductAttribute $productAttributeOriginal
  * @param CatalogProductAttribute $attribute
  * @param CatalogAttributeSet $attributeSet
  * @param CatalogProductAttributeIndex $attributeIndex
  * @param CatalogProductAttributeNew $attributeNew
  * @return array
  */
 public function testUpdateProductAttribute(CatalogProductAttribute $productAttributeOriginal, CatalogProductAttribute $attribute, CatalogAttributeSet $attributeSet, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew)
 {
     //Precondition
     $attributeSet->persist();
     $productAttributeOriginal->persist();
     $filter = ['attribute_code' => $productAttributeOriginal->getAttributeCode()];
     /** @var CatalogProductSimple $product */
     $product = $this->fixtureFactory->createByCode('catalogProductSimple', ['dataset' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $attributeSet]]]);
     $product->persist();
     $this->objectManager->create('Magento\\Catalog\\Test\\TestStep\\AddAttributeToAttributeSetStep', ['attribute' => $productAttributeOriginal, 'attributeSet' => $attributeSet])->run();
     //Steps
     $attributeIndex->open();
     $attributeIndex->getGrid()->searchAndOpen($filter);
     $attributeNew->getAttributeForm()->fill($attribute);
     $attributeNew->getPageActions()->save();
     $attribute = $this->prepareAttribute($attribute, $productAttributeOriginal);
     return ['product' => $this->prepareProduct($product, $attribute, $attributeSet)];
 }
 /**
  * Assert that Delete Attribute button is absent for system attribute on attribute edit page.
  *
  * @param CatalogProductAttributeNew $attributeNew
  * @return void
  */
 public function processAssert(CatalogProductAttributeNew $attributeNew)
 {
     \PHPUnit_Framework_Assert::assertFalse($attributeNew->getPageActions()->checkDeleteButton(), "Button 'Delete Attribute' is present on Attribute page");
 }
 /**
  * Click "Save" button on attribute edit page.
  *
  * @return void
  */
 public function run()
 {
     $this->attributeNew->getPageActions()->save();
 }