/** * 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]; }
/** * Assert that displayed attribute data on edit page equals passed from fixture. * * @param CatalogProductAttributeIndex $catalogProductAttributeIndex * @param CatalogProductAttributeNew $catalogProductAttributeNew * @param CatalogProductAttribute $attribute * @throws \Exception * @return void */ public function processAssert(CatalogProductAttributeIndex $catalogProductAttributeIndex, CatalogProductAttributeNew $catalogProductAttributeNew, CatalogProductAttribute $attribute) { $filter = ['attribute_code' => $attribute->getAttributeCode()]; $catalogProductAttributeIndex->open()->getGrid()->searchAndOpen($filter); $errors = $this->verifyData($attribute->getData(), $catalogProductAttributeNew->getAttributeForm()->getData($attribute)); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); }
/** * Run delete system product attribute test * * @param CatalogProductAttribute $productAttribute * @param CatalogProductAttributeIndex $attributeIndex * @return void */ public function testDeleteSystemProductAttribute(CatalogProductAttribute $productAttribute, CatalogProductAttributeIndex $attributeIndex) { $filter = $productAttribute->getData(); // Steps $attributeIndex->open(); $attributeIndex->getGrid()->searchAndOpen($filter); }
/** * 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)]; }
/** * Look on the scope of product attribute in the grid. * * @param CatalogProductAttributeIndex $catalogProductAttributeIndex * @param CatalogProductAttribute $attribute * @return void */ public function processAssert(CatalogProductAttributeIndex $catalogProductAttributeIndex, CatalogProductAttribute $attribute) { $filter = ['frontend_label' => $attribute->getFrontendLabel(), 'is_global' => $attribute->getIsGlobal()]; \PHPUnit_Framework_Assert::assertTrue($catalogProductAttributeIndex->open()->getGrid()->isRowVisible($filter), 'Attribute is not global.'); }
/** * Open Catalog Product Attribute Index. * * @return void */ public function run() { $this->catalogProductAttributeIndex->open(); }
/** * Assert that created product attribute is found in grid * * @param CatalogProductAttribute $attribute * @param CatalogProductAttributeIndex $attributeIndexPage * @return void */ public function processAssert(CatalogProductAttribute $attribute, CatalogProductAttributeIndex $attributeIndexPage) { $attributeIndexPage->open(); $code = $attribute->getAttributeCode(); \PHPUnit_Framework_Assert::assertTrue($attributeIndexPage->getGrid()->isRowVisible(['attribute_code' => $code]), 'Attribute with attribute code "' . $code . '" is absent in attribute grid.'); }
/** * Assert that after deleted product attribute cannot be found by attribute code. * * @param CatalogProductAttributeIndex $attributeIndex * @param CatalogProductAttribute $attribute * @return void */ public function processAssert(CatalogProductAttributeIndex $attributeIndex, CatalogProductAttribute $attribute) { $filter = ['attribute_code' => $attribute->getAttributeCode()]; $attributeIndex->open(); \PHPUnit_Framework_Assert::assertFalse($attributeIndex->getGrid()->isRowVisible($filter), 'Attribute \'' . $attribute->getFrontendLabel() . '\' is present in Attribute grid.'); }