/**
  * Assert that product attribute is global.
  *
  * @param CatalogProductAttribute $attribute
  * @param CatalogProductAttributeIndex $attributeIndexPage
  * @return void
  */
 public function processAssert(CatalogProductAttribute $attribute, CatalogProductAttributeIndex $attributeIndexPage)
 {
     $attributeIndexPage->open();
     $code = $attribute->getAttributeCode();
     $filter = ['attribute_code' => $code, 'is_global' => $attribute->getIsGlobal()];
     \PHPUnit_Framework_Assert::assertTrue($attributeIndexPage->getGrid()->isRowVisible($filter), "Attribute with attribute code '{$code}' isn't global.");
 }
 /**
  * Check whether attribute is displayed in the advanced search form on the frontend.
  *
  * @param CatalogProductAttribute $attribute
  * @param CatalogsearchAdvanced $advancedSearch
  * @return void
  */
 public function processAssert(CatalogProductAttribute $attribute, CatalogsearchAdvanced $advancedSearch)
 {
     $advancedSearch->open();
     $formLabels = $advancedSearch->getForm()->getFormlabels();
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue(in_array($label, $formLabels), 'Attribute is absent on advanced search form.');
 }
 /**
  * Check whether there is an opportunity to compare products using given attribute.
  *
  * @param InjectableFixture $product
  * @param CatalogProductAttribute $attribute
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductCompare $catalogProductCompare
  * @return void
  */
 public function processAssert(InjectableFixture $product, CatalogProductAttribute $attribute, BrowserInterface $browser, CatalogProductView $catalogProductView, CatalogProductCompare $catalogProductCompare)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCompare();
     $catalogProductCompare->open();
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue($catalogProductCompare->getCompareProductsBlock()->isAttributeVisible($label), 'Attribute is absent on product compare page.');
 }
 /**
  * Assert that displayed attribute data on edit page equals passed from fixture.
  *
  * @param CatalogProductAttributeIndex $catalogProductAttributeIndex
  * @param CatalogProductAttributeEdit $catalogProductAttributeEdit
  * @param CatalogProductAttribute $attribute
  * @return void
  */
 public function processAssert(CatalogProductAttributeIndex $catalogProductAttributeIndex, CatalogProductAttributeEdit $catalogProductAttributeEdit, CatalogProductAttribute $attribute)
 {
     $filter = ['attribute_code' => $attribute->getAttributeCode()];
     $catalogProductAttributeIndex->open()->getGrid()->searchAndOpen($filter);
     $dataFixture = $attribute->getData();
     $dataForm = $catalogProductAttributeEdit->getAttributeForm()->getData($attribute);
     $errors = $this->verifyData($dataFixture, $dataForm);
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
 /**
  * Assert that after save a product template on edit product set page displays:
  * 1. Correct product template 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 [optional]
  * @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());
     if ($productAttribute !== null) {
         $attributeLabel = $productAttribute->getFrontendLabel();
         \PHPUnit_Framework_Assert::assertTrue($productSetEdit->getAttributeSetEditBlock()->checkProductAttribute($attributeLabel), "Product Attribute '{$attributeLabel}' is absent on Product Template Groups.");
     }
 }
 /**
  * Assert that configurable options available on configurable product Edit form on backend.
  *
  * @param CatalogProduct $catalogProductIndex
  * @param CatalogProductEdit $catalogProductEdit
  * @param CatalogProductAttribute $attribute
  * @param InjectableFixture $product
  * @return void
  */
 public function processAssert(CatalogProduct $catalogProductIndex, CatalogProductEdit $catalogProductEdit, CatalogProductAttribute $attribute, InjectableFixture $product)
 {
     $options = $attribute->getOptions();
     $attributeOptionsFromFixture = [];
     foreach ($options as $option) {
         $attributeOptionsFromFixture[] = $option['admin'];
     }
     $catalogProductIndex->open()->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
     $productForm = $catalogProductEdit->getProductForm();
     $attributeOptions = $productForm->getAttributeElement($attribute)->getValues();
     \PHPUnit_Framework_Assert::assertEquals($attributeOptionsFromFixture, $attributeOptions);
 }
 /**
  * Prepare filter for search.
  *
  * @param InjectableFixture $product
  * @param CatalogProductAttribute $attribute
  * @return string
  */
 protected function prepareFilter(InjectableFixture $product, CatalogProductAttribute $attribute)
 {
     $filter = '';
     $attributesFillData = $product->getAttributes();
     $attributeOptions = $attribute->getOptions();
     foreach ($attributesFillData['preset'] as $optionsFillData) {
         foreach ($optionsFillData as $optionKey) {
             $optionKey = str_replace('option_key_', '', $optionKey);
             $filter .= isset($attributeOptions[$optionKey]['view']) ? $attributeOptions[$optionKey]['view'] : $attributeOptions[$optionKey]['admin'];
         }
     }
     return $filter;
 }
 /**
  * Prepare attribute fixture.
  *
  * @return void
  */
 protected function prepareAttribute()
 {
     $data = $this->attribute->getData();
     if (isset($data['options'])) {
         $data['options'] = $this->prepareOptionsData($data['options']);
     }
     $data['attribute_id'] = $this->attributeEdit->getAttributeForm()->getAttributeId();
     $this->attribute = $this->fixtureFactory->createByCode('catalogProductAttribute', ['data' => $data]);
 }
 /**
  * Assert that created attribute is displayed on product form.
  *
  * @param InjectableFixture $product
  * @param CatalogProduct $productGrid
  * @param CatalogProductEdit $productEdit
  * @param CatalogProductAttribute $attribute
  * @return void
  */
 public function processAssert(InjectableFixture $product, CatalogProduct $productGrid, CatalogProductEdit $productEdit, CatalogProductAttribute $attribute)
 {
     $productGrid->open();
     $productGrid->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
     \PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->checkAttributeLabel($attribute->getData()), "Product Attribute is absent on Product form.");
 }
 /**
  * Assert that attribute present in sort dropdown on search results page on frontend.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogsearchResult $catalogsearchResult
  * @param CatalogProductAttribute $attribute
  * @param InjectableFixture $product
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogsearchResult $catalogsearchResult, CatalogProductAttribute $attribute, InjectableFixture $product)
 {
     $cmsIndex->open()->getSearchBlock()->search($product->getName());
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue(in_array($label, $catalogsearchResult->getListProductBlock()->getSortByValues()), 'Attribute is absent in sort dropdown on search results page on frontend.');
 }
 /**
  * Check out if the attribute in the navigation bar on the search results page in Layered navigation.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogsearchResult $catalogsearchResult
  * @param InjectableFixture $product
  * @param CatalogProductAttribute $attribute
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogsearchResult $catalogsearchResult, InjectableFixture $product, CatalogProductAttribute $attribute)
 {
     $cmsIndex->open()->getSearchBlock()->search($product->getName());
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue(in_array(strtoupper($label), $catalogsearchResult->getLayeredNavigationBlock()->getFilters()), 'Attribute is absent in layered navigation on search page.');
 }
 /**
  * Check whether the attribute filter is displayed on the frontend in Layered navigation.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param InjectableFixture $product
  * @param CatalogProductAttribute $attribute
  * @param CmsIndex $cmsIndex
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, InjectableFixture $product, CatalogProductAttribute $attribute, CmsIndex $cmsIndex)
 {
     $cmsIndex->open()->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue(in_array(strtoupper($label), $catalogCategoryView->getLayeredNavigationBlock()->getFilters()), 'Attribute is absent in layered navigation on category page.');
 }
Exemplo n.º 13
0
 /**
  * Get attribute element.
  *
  * @param CatalogProductAttribute $attribute
  * @return CustomAttribute
  */
 public function getAttributeElement(CatalogProductAttribute $attribute)
 {
     return $this->_rootElement->find(sprintf($this->attributeBlock, $attribute->getFrontendLabel()), Locator::SELECTOR_XPATH, 'Mage\\Adminhtml\\Test\\Block\\Catalog\\Product\\Attribute\\CustomAttribute');
 }
 /**
  * Assert that created product attribute exist 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.');
 }
 /**
  * Run CreateAttributeSetEntity test.
  *
  * @param CatalogAttributeSet $attributeSet
  * @param CatalogProductAttribute $productAttribute
  * @return void
  */
 public function test(CatalogAttributeSet $attributeSet, CatalogProductAttribute $productAttribute)
 {
     // Precondition
     $productAttribute->persist();
     // Steps:
     $this->productSetIndex->open();
     $this->productSetIndex->getPageActionsBlock()->addNew();
     $this->productSetAdd->getAttributeSetForm()->fill($attributeSet);
     $this->productSetAdd->getPageActions()->save();
     $this->productSetEdit->getAttributeSetEditBlock()->moveAttribute($productAttribute->getData());
     $this->productSetEdit->getPageActions()->save();
 }