/** * Move attribute To attribute set. * * @return array */ public function run() { $filterAttribute = ['set_name' => $this->attributeSet->getAttributeSetName()]; $this->catalogProductSetIndex->open()->getGrid()->searchAndOpen($filterAttribute); $this->catalogProductSetEdit->getAttributeSetEditBlock()->moveAttribute($this->attribute->getData()); $this->catalogProductSetEdit->getPageActions()->save(); }
/** * Prepare Catalog Attribute Set data * * @param CatalogAttributeSet $attributeSet * @return void */ protected function prepareData(CatalogAttributeSet $attributeSet) { if (!$attributeSet->hasData('attribute_set_id')) { $attributeSet->persist(); } $this->data = $attributeSet->getAttributeSetName(); $this->attributeSet = $attributeSet; }
/** * Assert that deleted attribute isn't displayed in Attribute set's Unassigned Attributes section * * @param CatalogAttributeSet $attributeSet * @param CatalogProductSetIndex $productSetIndex * @param CatalogProductSetEdit $productSetEdit * @return void */ public function processAssert(CatalogAttributeSet $attributeSet, CatalogProductSetIndex $productSetIndex, CatalogProductSetEdit $productSetEdit) { $filter = ['set_name' => $attributeSet->getAttributeSetName()]; $productSetIndex->open(); $productSetIndex->getGrid()->searchAndOpen($filter); $attributeCode = $attributeSet->getDataFieldConfig('assigned_attributes')['source']->getAttributes()[0]->getAttributeCode(); \PHPUnit_Framework_Assert::assertFalse($productSetEdit->getAttributeSetEditBlock()->checkUnassignedProductAttribute($attributeCode), "Attribute " . $attributeCode . " is present in Unassigned Attribute set's section."); }
/** * 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(); }
/** * Assert that deleted attribute can't be mapped to Google Attribute (attribute doesn't appear in Attributes * Mapping -> Google Content - Attributes after selecting attribute set) * * @param FixtureFactory $fixtureFactory * @param CatalogAttributeSet $productTemplate * @param GoogleShoppingTypesIndex $shoppingTypesIndex * @param GoogleShoppingTypesNew $shoppingTypesNew * @return void */ public function processAssert(FixtureFactory $fixtureFactory, CatalogAttributeSet $productTemplate, GoogleShoppingTypesIndex $shoppingTypesIndex, GoogleShoppingTypesNew $shoppingTypesNew) { $shoppingTypesIndex->open(); $shoppingTypesIndex->getPageActionsBlock()->addNew(); $shoppingAttributes = $fixtureFactory->createByCode('googleShoppingAttribute', ['dataSet' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $productTemplate]]]); $shoppingTypesNew->getGoogleShoppingForm()->fill($shoppingAttributes); $shoppingTypesNew->getGoogleShoppingForm()->clickAddNewAttribute(); $attributeCode = $productTemplate->getDataFieldConfig('assigned_attributes')['source']->getAttributes()[0]->getAttributeCode(); \PHPUnit_Framework_Assert::assertFalse($shoppingTypesNew->getGoogleShoppingForm()->findAttribute($attributeCode), "Attribute " . $attributeCode . " is present in Attribute set mapping"); }
/** * Move attribute To attribute set. * * @return array */ public function run() { $filterAttribute = ['set_name' => $this->productTemplate->getAttributeSetName()]; $this->catalogProductSetIndex->open()->getGrid()->searchAndOpen($filterAttribute); $this->catalogProductSetEdit->getAttributeSetEditBlock()->moveAttribute($this->attribute->getData()); $this->catalogProductSetEdit->getPageActions()->save(); // Create product with attribute set mentioned above: $product = $this->fixtureFactory->createByCode('catalogProductSimple', ['dataset' => 'product_with_category_with_anchor', 'data' => ['attribute_set_id' => ['attribute_set' => $this->productTemplate]]]); $product->persist(); return ['product' => $product]; }
/** * 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]; }
/** * Assert that after save a attribute set on edit product set page displays: * 1. Correct attribute set name in Attribute set name field passed from fixture * 2. Created Product Attribute (if was added) * * @param CatalogProductSetIndex $productSet * @param CatalogProductSetEdit $productSetEdit * @param CatalogAttributeSet $attributeSet * @param CatalogProductAttribute $productAttribute * @return void */ public function processAssert(CatalogProductSetIndex $productSet, CatalogProductSetEdit $productSetEdit, CatalogAttributeSet $attributeSet, CatalogProductAttribute $productAttribute = null) { $filterAttribute = ['set_name' => $attributeSet->getAttributeSetName()]; $productSet->open(); $productSet->getGrid()->searchAndOpen($filterAttribute); \PHPUnit_Framework_Assert::assertEquals($filterAttribute['set_name'], $productSetEdit->getAttributeSetEditBlock()->getAttributeSetName(), 'Attribute Set not found' . "\nExpected: " . $filterAttribute['set_name'] . "\nActual: " . $productSetEdit->getAttributeSetEditBlock()->getAttributeSetName()); if ($productAttribute !== null) { $attributeLabel = $productAttribute->getFrontendLabel(); \PHPUnit_Framework_Assert::assertTrue($productSetEdit->getAttributeSetEditBlock()->checkProductAttribute($attributeLabel), "Product Attribute is absent on Attribute Set Groups"); } }
/** * 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]; }
/** * Assert that created product template: * 1. Displays in product template suggest container dropdown * 2. Can be used for new created product. * * @param FixtureFactory $fixtureFactory * @param CatalogProductEdit $productEdit * @param CatalogProductIndex $productGrid * @param CatalogAttributeSet $attributeSet * @param CatalogProductNew $newProductPage * @param CatalogProductAttribute $productAttributeOriginal * @return void */ public function processAssert(FixtureFactory $fixtureFactory, CatalogProductEdit $productEdit, CatalogProductIndex $productGrid, CatalogAttributeSet $attributeSet, CatalogProductNew $newProductPage, CatalogProductAttribute $productAttributeOriginal) { $productGrid->open(); $productGrid->getGridPageActionBlock()->addProduct('simple'); $productBlockForm = $newProductPage->getProductForm(); /**@var CatalogProductSimple $catalogProductSimple */ $productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $attributeSet]]]); $productBlockForm->fill($productSimple); \PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->isCustomTabVisible($attributeSet->getGroup()), "Product Group is absent on Product form tabs."); $productEdit->getProductForm()->openCustomTab($attributeSet->getGroup()); \PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->checkAttributeLabel($productAttributeOriginal), "Product Attribute is absent on Product form."); }
/** * 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 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 DeleteAttributeSet test * * @param FixtureFactory $fixtureFactory * @param CatalogAttributeSet $productTemplate * @return array */ public function test(FixtureFactory $fixtureFactory, CatalogAttributeSet $productTemplate) { // Precondition $productTemplate->persist(); $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $productTemplate]]]); $product->persist(); // Steps $filter = ['set_name' => $productTemplate->getAttributeSetName()]; $this->productSetIndex->open(); $this->productSetIndex->getGrid()->searchAndOpen($filter); $this->productSetEdit->getPageActions()->delete(); return ['product' => $product]; }
/** * Assert that created product template: * 1. Displays in product template suggest container dropdown * 2. Can be used for new created product. * * @param FixtureFactory $fixtureFactory * @param CatalogProductEdit $productEdit * @param CatalogProductIndex $productGrid * @param CatalogAttributeSet $attributeSet * @param CatalogProductNew $newProductPage * @param CatalogProductAttribute $productAttribute * @return void */ public function processAssert(FixtureFactory $fixtureFactory, CatalogProductEdit $productEdit, CatalogProductIndex $productGrid, CatalogAttributeSet $attributeSet, CatalogProductNew $newProductPage, CatalogProductAttribute $productAttribute) { $productGrid->open(); $productGrid->getProductBlock()->addProduct('simple'); $productBlockForm = $newProductPage->getForm(); /**@var CatalogProductSimple $catalogProductSimple */ $productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $attributeSet]]]); $productBlockForm->fillProduct($productSimple); $newProductPage->getFormAction()->save(); $formData = $productEdit->getForm()->getData($productSimple); $formAttributeSet = $formData['attribute_set_id']; \PHPUnit_Framework_Assert::assertEquals($attributeSet->getAttributeSetName(), $formAttributeSet, 'Attribute Set not found on Product form.' . "\nExpected: " . $attributeSet->getAttributeSetName() . "\nActual: " . $formAttributeSet); $productEdit->getForm()->openTab('product-details'); \PHPUnit_Framework_Assert::assertTrue($productEdit->getForm()->checkAttributeLabel($productAttribute), "Product Attribute is absent on Product form."); }
/** * 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 UpdateProductTemplate test * * @param CatalogAttributeSet $attributeSet * @param CatalogAttributeSet $attributeSetOriginal * @param CatalogProductAttribute $productAttributeOriginal * @return void */ public function test(CatalogAttributeSet $attributeSet, CatalogAttributeSet $attributeSetOriginal, CatalogProductAttribute $productAttributeOriginal) { // Precondition $attributeSetOriginal->persist(); $productAttributeOriginal->persist(); // Steps $filter = ['set_name' => $attributeSetOriginal->getAttributeSetName()]; $this->productSetIndex->open(); $this->productSetIndex->getGrid()->searchAndOpen($filter); $groupName = $attributeSet->getGroup(); $this->productSetEdit->getAttributeSetEditBlock()->addAttributeSetGroup($groupName); $this->productSetEdit->getAttributeSetEditBlock()->moveAttribute($productAttributeOriginal->getData(), $groupName); $this->productSetEdit->getAttributeSetEditForm()->fill($attributeSet); $this->productSetEdit->getPageActions()->save(); }
/** * Add this attribute to Default attribute Template. Create product and Assert that created attribute * is displayed on product form (Products > Inventory > Catalog) * * @param FixtureFactory $fixtureFactory * @param CatalogProductSetIndex $productSet * @param CatalogProductSetEdit $productSetEdit * @param CatalogAttributeSet $productTemplate * @param CatalogProductIndex $productGrid * @param CatalogProductAttribute $productAttributeOriginal * @param CatalogProductEdit $productEdit * @param CatalogProductAttribute|null $productAttribute * @return void */ public function processAssert(FixtureFactory $fixtureFactory, CatalogProductSetIndex $productSet, CatalogProductSetEdit $productSetEdit, CatalogAttributeSet $productTemplate, CatalogProductIndex $productGrid, CatalogProductEdit $productEdit, CatalogProductAttribute $productAttribute, CatalogProductAttribute $productAttributeOriginal = null) { $filterAttribute = ['set_name' => $productTemplate->getAttributeSetName()]; $productSet->open(); $productSet->getGrid()->searchAndOpen($filterAttribute); $attributeData = $productAttributeOriginal !== null ? array_merge($productAttribute->getData(), $productAttributeOriginal->getData()) : $productAttribute->getData(); $productSetEdit->getAttributeSetEditBlock()->moveAttribute($attributeData, 'Product Details'); $productSetEdit->getPageActions()->save(); $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_with_category', 'data' => ['attribute_set_id' => ['attribute_set' => $productTemplate]]]); $product->persist(); $filterProduct = ['sku' => $product->getSku()]; $productGrid->open(); $productGrid->getProductGrid()->searchAndOpen($filterProduct); $catalogProductAttribute = $productAttributeOriginal !== null ? array_merge($productAttributeOriginal->getData(), $productAttribute->getData()) : $productAttribute->getData(); \PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->checkAttributeLabel($catalogProductAttribute), "Product Attribute is absent on Product form."); }
/** * Create attribute set. * * @return FixtureInterface */ protected function createAttributeSet() { if (!$this->attributeSet) { $this->attributeSet = $this->fixtureFactory->createByCode('catalogAttributeSet', ['dataset' => 'custom_attribute_set', 'data' => ['assigned_attributes' => ['attributes' => array_values($this->attributes)]]]); $this->attributeSet->persist(); } return $this->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)]; }
/** * Move attribute To attribute set. * * @return array */ public function run() { $filterAttribute = ['set_name' => $this->attributeSet->getAttributeSetName()]; $this->catalogProductSetIndex->open()->getGrid()->searchAndOpen($filterAttribute); $this->catalogProductSetEdit->getAttributeSetEditBlock()->moveAttribute($this->attribute->getData()); $this->catalogProductSetEdit->getPageActions()->save(); // Create product with attribute set mentioned above: $customAttribute = $this->attribute; if ($this->attributeValue !== null) { $customAttribute = ['value' => $this->attributeValue, 'attribute' => $customAttribute]; } $product = $this->fixtureFactory->createByCode('catalogProductSimple', ['dataset' => 'product_with_category_with_anchor', 'data' => ['attribute_set_id' => ['attribute_set' => $this->attributeSet], 'custom_attribute' => $customAttribute]]); $this->catalogProductIndex->open()->getGridPageActionBlock()->addProduct('simple'); $productForm = $this->catalogProductEdit->getProductForm(); $productForm->fill($product); $this->catalogProductEdit->getFormPageActions()->save(); return ['product' => $product]; }
/** * Assert that product template is not displayed in Product Templates grid * * @param CatalogProductSetIndex $productSetPage * @param CatalogAttributeSet $productTemplate * @return void */ public function processAssert(CatalogProductSetIndex $productSetPage, CatalogAttributeSet $productTemplate) { $filterAttributeSet = ['set_name' => $productTemplate->getAttributeSetName()]; $productSetPage->open(); \PHPUnit_Framework_Assert::assertFalse($productSetPage->getGrid()->isRowVisible($filterAttributeSet), 'An attribute set named "' . $filterAttributeSet['set_name'] . '" is present in Product Template grid.'); }
/** * Assert that new attribute set displays in Attribute Sets grid * * @param CatalogProductSetIndex $productSetPage * @param CatalogAttributeSet $attributeSet * @return void */ public function processAssert(CatalogProductSetIndex $productSetPage, CatalogAttributeSet $attributeSet) { $filterAttributeSet = ['set_name' => $attributeSet->getAttributeSetName()]; $productSetPage->open(); \PHPUnit_Framework_Assert::assertTrue($productSetPage->getGrid()->isRowVisible($filterAttributeSet), 'Attribute Set \'' . $filterAttributeSet['set_name'] . '\' is absent in Attribute Set grid.'); }
/** * Get Default Attribute Set page with curl * * @param CatalogAttributeSet $fixture * @return string */ protected function getDefaultAttributeSet(CatalogAttributeSet $fixture) { $url = $_ENV['app_backend_url'] . 'catalog/product_set/edit/id/' . $fixture->getAttributeSetId() . '/'; $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); $curl->write($url, [], CurlInterface::GET); $response = $curl->read(); $curl->close(); return $response; }