コード例 #1
0
 /**
  * Run update product simple entity test
  *
  * @param CatalogProductSimple $product
  * @return void
  */
 public function testUpdate(CatalogProductSimple $product)
 {
     $filter = ['sku' => $this->product->getSku()];
     $this->productGrid->open()->getProductGrid()->searchAndOpen($filter);
     $this->editProductPage->getProductForm()->fill($product);
     $this->editProductPage->getFormPageActions()->save();
 }
コード例 #2
0
 /**
  * Run update product simple entity test
  *
  * @param CatalogProductSimple $initialProduct
  * @param CatalogProductSimple $product
  * @return array
  */
 public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product)
 {
     // Preconditions
     $initialProduct->persist();
     $initialCategory = $initialProduct->hasData('category_ids') ? $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0] : null;
     $category = $product->hasData('category_ids') && $product->getCategoryIds()[0] ? $product->getDataFieldConfig('category_ids')['source']->getCategories()[0] : $initialCategory;
     // Steps
     $filter = ['sku' => $initialProduct->getSku()];
     $this->productGrid->open();
     $this->productGrid->getProductGrid()->searchAndOpen($filter);
     $this->editProductPage->getProductForm()->fill($product);
     $this->editProductPage->getFormPageActions()->save();
     return ['category' => $category];
 }
コード例 #3
0
 /**
  * Run mass update product simple entity test.
  *
  * @param CatalogProductSimple $initialProduct
  * @param CatalogProductSimple $product
  * @param string $configData
  * @return array
  */
 public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product, $configData)
 {
     $this->configData = $configData;
     // Preconditions
     $initialProduct->persist();
     $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $configData])->run();
     // Steps
     $this->productGrid->open();
     $this->productGrid->getProductGrid()->updateAttributes([['sku' => $initialProduct->getSku()]]);
     $this->attributeMassActionPage->getAttributesBlockForm()->fill($product);
     $this->attributeMassActionPage->getFormPageActions()->save();
     $data = array_merge($initialProduct->getData(), $product->getData());
     $product = $this->objectManager->create('Magento\\Catalog\\Test\\Fixture\\CatalogProductSimple', ['data' => $data]);
     return ['category' => $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0], 'product' => $product];
 }
コード例 #4
0
 /**
  * Run update product simple entity test.
  *
  * @param CatalogProductSimple $initialProduct
  * @param CatalogProductSimple $product
  * @param string $configData
  * @return array
  */
 public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product, $configData = '')
 {
     $this->configData = $configData;
     // Preconditions
     $initialProduct->persist();
     $initialCategory = $initialProduct->hasData('category_ids') ? $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0] : null;
     $category = $product->hasData('category_ids') && $product->getCategoryIds()[0] ? $product->getDataFieldConfig('category_ids')['source']->getCategories()[0] : $initialCategory;
     $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $configData])->run();
     // Steps
     $filter = ['sku' => $initialProduct->getSku()];
     $this->productGrid->open();
     $this->productGrid->getProductGrid()->searchAndOpen($filter);
     $this->editProductPage->getProductForm()->fill($product);
     $this->editProductPage->getFormPageActions()->save();
     return ['category' => $category];
 }
コード例 #5
0
 /**
  * Assert data on the product view page
  *
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 protected function assertOnProductView(CatalogProductSimple $product, CatalogProductView $catalogProductView)
 {
     $viewBlock = $catalogProductView->getViewBlock();
     $price = $viewBlock->getPriceBlock()->getPrice();
     $name = $viewBlock->getProductName();
     $sku = $viewBlock->getProductSku();
     \PHPUnit_Framework_Assert::assertEquals($product->getName(), $name, 'Product name on product view page is not correct.');
     \PHPUnit_Framework_Assert::assertEquals($product->getSku(), $sku, 'Product sku on product view page is not correct.');
     if (isset($price['price_regular_price'])) {
         \PHPUnit_Framework_Assert::assertEquals(number_format($product->getPrice(), 2), $price['price_regular_price'], 'Product regular price on product view page is not correct.');
     }
     $priceComparing = false;
     if ($specialPrice = $product->getSpecialPrice()) {
         $priceComparing = $specialPrice;
     }
     if ($priceComparing && isset($price['price_special_price'])) {
         \PHPUnit_Framework_Assert::assertEquals(number_format($priceComparing, 2), $price['price_special_price'], 'Product special price on product view page is not correct.');
     }
 }