/**
  * Check whether the attribute is mandatory.
  *
  * @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)
 {
     $catalogProductIndex->open()->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
     $productForm = $catalogProductEdit->getProductForm();
     $productForm->getAttributeElement($attribute)->setValue('');
     $catalogProductEdit->getFormPageActions()->save();
     $failedAttributes = $productForm->getRequireNoticeAttributes($product);
     $actualMessage = $failedAttributes['general'][$attribute->getFrontendLabel()];
     \PHPUnit_Framework_Assert::assertEquals(self::REQUIRE_MESSAGE, $actualMessage, 'JS error notice on product edit page is not equal to expected.');
 }
 /**
  * Assert form data equals fixture data.
  *
  * @param InjectableFixture $product
  * @param CatalogProduct $productGrid
  * @param CatalogProductEdit $productPage
  * @param string $urlKeyFormat [optional]
  * @return void
  */
 public function processAssert(InjectableFixture $product, CatalogProduct $productGrid, CatalogProductEdit $productPage, $urlKeyFormat = '%s')
 {
     $this->product = $product;
     $this->urlKeyFormat = $urlKeyFormat;
     $this->catalogProductEdit = $productPage;
     $filter = ['name' => $product->getName(), 'status' => 'Disabled'];
     $productGrid->open()->getProductGrid()->searchAndOpen($filter);
     $formData = $productPage->getProductForm()->getData($product);
     $fixtureData = $this->prepareFixtureData($product->getData());
     $errors = $this->verifyData($fixtureData, $formData);
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
 /**
  * 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);
 }
 /**
  * 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 CatalogProduct $productGrid
  * @param CatalogAttributeSet $attributeSet
  * @param CatalogAttributeSet $attributeSetOriginal
  * @param CatalogProductNew $newProductPage
  * @param CatalogProductAttribute $productAttribute
  * @return void
  */
 public function processAssert(FixtureFactory $fixtureFactory, CatalogProductEdit $productEdit, CatalogProduct $productGrid, CatalogAttributeSet $attributeSet, CatalogProductNew $newProductPage, CatalogProductAttribute $productAttribute, CatalogAttributeSet $attributeSetOriginal = null)
 {
     $productGrid->open();
     $productGrid->getGridPageActionBlock()->addNew();
     /**@var CatalogProductSimple $productSimple */
     $productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $attributeSet]]]);
     $newProductPage->getProductForm()->fill($productSimple);
     $newProductPage->getFormPageActions()->saveAndContinue();
     $attributeSetName = $attributeSet->getAttributeSetName();
     \PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->checkAttributeSet($attributeSetName), "Product isn't in '{$attributeSetName}' Attribute Set.");
     if ($attributeSetOriginal === null) {
         $productEdit->getProductForm()->openTab('general');
         \PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->checkAttributeLabel($productAttribute), "Product Attribute is absent on Product form.");
     }
 }
 /**
  * Run test duplicate product entity.
  *
  * @param string $productType
  * @return array
  */
 public function test($productType)
 {
     // Precondition
     $product = $this->createProduct($productType);
     // Steps
     $this->productGrid->open();
     $this->productGrid->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
     $this->editProductPage->getFormPageActions()->duplicate();
     return ['product' => $product];
 }
 /**
  * Run update product simple entity test.
  *
  * @param CatalogProductSimple $initialProduct
  * @param CatalogProductSimple $product
  * @return array
  */
 public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product)
 {
     // Preconditions
     $initialProduct->persist();
     // Steps
     $this->productGrid->open();
     $this->productGrid->getProductGrid()->searchAndOpen(['sku' => $initialProduct->getSku()]);
     $this->editProductPage->getProductForm()->fill($product);
     $this->editProductPage->getFormPageActions()->save();
     return ['category' => $this->getCategory($initialProduct, $product)];
 }
 /**
  * Add appurtenant products and save product.
  *
  * @param InjectableFixture $product
  * @param array $appurtenantData
  * @return void
  */
 protected function addAppurtenantProducts(InjectableFixture $product, array $appurtenantData)
 {
     $this->productGrid->open();
     $this->productGrid->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
     $form = $this->editProductPage->getProductForm();
     $form->openTab($this->tabName);
     $appurtenantTab = $form->getTabElement($this->tabName);
     $appurtenantData[$this->appurtenantType['formIndex']]['value'] = $this->prepareData($appurtenantData[$this->appurtenantType['formIndex']]['value']);
     $appurtenantTab->fillFormTab($appurtenantData);
     $this->editProductPage->getFormPageActions()->save();
 }
 /**
  * Prepares fixture data for comparison.
  *
  * @param array $data
  * @param array $sortFields [optional]
  * @return array
  */
 protected function prepareFixtureData(array $data, array $sortFields = [])
 {
     $data = array_diff_key($data, array_flip($this->skippedFixtureFields));
     if (!$this->catalogProductEdit->getProductForm()->getTabElement('websites')->isVisible()) {
         unset($data['website_ids']);
     }
     if (isset($data['website_ids']) && !is_array($data['website_ids'])) {
         $data['website_ids'] = [$data['website_ids']];
     }
     if (!empty($this->specialArray)) {
         $data = $this->prepareSpecialPriceArray($data);
     }
     foreach ($sortFields as $path) {
         $data = $this->sortDataByPath($data, $path);
     }
     return $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.");
 }
示例#10
0
 /**
  * Get special tab for configurable product.
  *
  * @return ConfigurableTab
  */
 protected function getConfigurableProductTab()
 {
     return $this->catalogProductEdit->getProductForm()->getTabElement('configurable');
 }
 /**
  * Save product.
  *
  * @return void
  */
 public function run()
 {
     $this->catalogProductEdit->getFormPageActions()->save();
 }
 /**
  * Open configurable specify tab.
  *
  * @return void
  */
 protected function openConfigurableTab()
 {
     $this->catalogProductEdit->getProductForm()->openTab('configurable');
 }
 /**
  * Checking the output message successful product duplication.
  *
  * @param CatalogProductEdit $productPage
  * @return void
  */
 public function processAssert(CatalogProductEdit $productPage)
 {
     \PHPUnit_Framework_Assert::assertEquals(self::DUPLICATE_MESSAGE, $productPage->getMessagesBlock()->getSuccessMessages());
 }