/** * 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]; }
/** * 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(); }
/** * 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."); }
/** * 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"); } }
/** * 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."); }
/** * 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.'); }