Ejemplo n.º 1
0
 /**
  * Assert product data on category and product pages
  *
  * @param Product $product
  * @return void
  */
 protected function assertOnCategory($product)
 {
     //Pages
     $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
     $categoryPage = Factory::getPageFactory()->getCatalogCategoryView();
     $productPage = Factory::getPageFactory()->getCatalogProductView();
     //Steps
     $frontendHomePage->open();
     $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName());
     //Verification on category product list
     $productListBlock = $categoryPage->getListProductBlock();
     $this->assertTrue($productListBlock->isProductVisible($product->getName()));
     $productListBlock->openProductViewPage($product->getName());
     //Verification on product detail page
     $productViewBlock = $productPage->getViewBlock();
     $this->assertEquals($product->getName(), $productViewBlock->getProductName());
     $price = $productViewBlock->getPriceBlock()->getPrice();
     $this->assertEquals(number_format($product->getProductPrice(), 2), $price);
     $productOptionsBlock = $productPage->getViewBlock()->getCustomOptionsBlock();
     $fixture = $product->getData('fields/custom_options/value');
     $actualOptions = $productOptionsBlock->getOptions($product);
     $this->assertCount(count($fixture), $actualOptions);
     $this->assertTrue(isset($actualOptions['custom_options'][$fixture[0]['title']]['options'][0]['title']));
     $this->assertEquals($fixture[0]['title'], $actualOptions['custom_options'][$fixture[0]['title']]['title']);
 }
Ejemplo n.º 2
0
 /**
  * Assert configurable product is added to cart together with the proper related product
  *
  * @param Product $product
  * @param Product[] $assigned
  * @return void
  */
 protected function assertOnTheFrontEnd(Product $product, array $assigned)
 {
     /** @var Product $simple2 */
     /** @var Product $configurable */
     list($simple2, $configurable) = $assigned;
     //Open up simple1 product page
     $productPage = Factory::getPageFactory()->getCatalogProductView();
     Factory::getClientBrowser()->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $this->assertEquals($product->getName(), $productPage->getViewBlock()->getProductName());
     /** @var \Magento\Catalog\Test\Block\Product\ProductList\Related $relatedBlock */
     $relatedBlock = $productPage->getRelatedProductBlock();
     //Verify related simple2 and configurable on Simple1 product page
     $this->assertTrue($relatedBlock->isRelatedProductVisible($simple2->getName()));
     $this->assertTrue($relatedBlock->isRelatedProductSelectable($simple2->getName()));
     $this->assertTrue($relatedBlock->isRelatedProductVisible($configurable->getName()));
     $this->assertFalse($relatedBlock->isRelatedProductSelectable($configurable->getName()));
     //Open and verify configurable page
     $relatedBlock->openRelatedProduct($configurable->getName());
     $this->assertEquals($configurable->getName(), $productPage->getViewBlock()->getProductName());
     //Verify related simple2 on Configurable product page and add to cart it
     $relatedBlock = $productPage->getRelatedProductBlock();
     $this->assertTrue($relatedBlock->isRelatedProductVisible($simple2->getName()));
     $this->assertTrue($relatedBlock->isRelatedProductSelectable($simple2->getName()));
     $relatedBlock->selectProductForAddToCart($simple2->getName());
     $productPage->getViewBlock()->addToCart($configurable);
     //Verify that both configurable product and simple product 2 are added to shopping cart
     $checkoutCartPage = Factory::getPageFactory()->getCheckoutCartIndex();
     $checkoutCartBlock = $checkoutCartPage->getCartBlock();
     $checkoutCartPage->getMessagesBlock()->waitSuccessMessage();
     $this->assertTrue($checkoutCartBlock->isProductInShoppingCart($configurable), 'Configurable product was not found in the shopping cart.');
     $this->assertTrue($checkoutCartBlock->isProductInShoppingCart($simple2), 'Related product was not found in the shopping cart.');
 }
 /**
  * Assert absence product on category page (frontend)
  *
  * @param Product $product
  * @return void
  */
 protected function assertAbsenceOnCategory(Product $product)
 {
     //Pages
     $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
     $categoryPage = Factory::getPageFactory()->getCatalogCategoryView();
     //Steps
     $frontendHomePage->open();
     $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName());
     //Verification on category product list
     $productListBlock = $categoryPage->getListProductBlock();
     $this->assertFalse($productListBlock->isProductVisible($product->getName()));
 }
Ejemplo n.º 4
0
 /**
  * {inheritdoc}
  */
 protected function _initData()
 {
     parent::_initData();
     $this->_dataConfig = array('type_id' => 'downloadable', 'constraint' => 'Success', 'grid_filter' => array('name'), 'create_url_params' => array('type' => 'downloadable', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID), 'input_prefix' => 'product');
     $data = array('is_virtual' => ['value' => '', 'group' => null], 'price' => ['value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS], 'qty' => array('value' => 1000, 'group' => static::GROUP_PRODUCT_DETAILS, 'input_name' => 'product[quantity_and_stock_status][qty]'), 'quantity_and_stock_status' => array('value' => 'In Stock', 'input_value' => 1, 'group' => static::GROUP_PRODUCT_DETAILS, 'input_name' => 'product[quantity_and_stock_status][is_in_stock]'), 'product_website_1' => array('value' => 'Yes', 'input_value' => 1, 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'product[website_ids][]'));
     $this->_data['fields'] = $data + $this->_data['fields'];
     $this->_repository = Factory::getRepositoryFactory()->getMagentoDownloadableDownloadableProduct($this->_dataConfig, $this->_data);
 }
Ejemplo n.º 5
0
 /**
  * {inheritdoc}
  */
 protected function _initData()
 {
     parent::_initData();
     $this->_dataConfig = array('constraint' => 'Success', 'grid_filter' => array('name'), 'create_url_params' => array('type' => 'downloadable', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID), 'input_prefix' => 'product');
     $data = array('is_virtual' => ['value' => '', 'group' => null], 'price' => ['value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS]);
     $this->_data['fields'] = $data + $this->_data['fields'];
     $this->_repository = Factory::getRepositoryFactory()->getMagentoDownloadableDownloadableProduct($this->_dataConfig, $this->_data);
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 protected function _initData()
 {
     parent::_initData();
     $this->_dataConfig = ['constraint' => 'Success', 'grid_filter' => ['name'], 'create_url_params' => ['type' => 'virtual', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID], 'input_prefix' => 'product'];
     $data = ['is_virtual' => ['value' => '', 'group' => null], 'price' => ['value' => 15, 'group' => static::GROUP_PRODUCT_DETAILS], 'tax_class_id' => ['value' => 'Taxable Goods', 'input_value' => '2', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'qty' => ['value' => 1000, 'group' => static::GROUP_PRODUCT_DETAILS, 'input_name' => 'product[quantity_and_stock_status][qty]'], 'product_website_1' => ['value' => 'Yes', 'input_value' => 1, 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'product[website_ids][]'], 'inventory_manage_stock' => ['value' => 'No', 'input_value' => '0', 'group' => static::GROUP_PRODUCT_INVENTORY, 'input' => 'select', 'input_name' => 'product[stock_data][manage_stock]']];
     $this->_data['fields'] = array_merge($this->_data['fields'], $data);
     $this->_repository = Factory::getRepositoryFactory()->getMagentoCatalogVirtualProduct($this->_dataConfig, $this->_data);
 }
Ejemplo n.º 7
0
 /**
  * {inheritdoc}
  */
 protected function _initData()
 {
     parent::_initData();
     $this->_dataConfig = array('constraint' => 'Success', 'grid_filter' => array('name'), 'create_url_params' => array('type' => 'simple', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID), 'input_prefix' => 'product');
     $data = $this->_getPreparedData();
     $this->_data['fields'] = array_merge($this->_data['fields'], $data);
     $this->_repository = Factory::getRepositoryFactory()->getMagentoCatalogSimpleProduct($this->_dataConfig, $this->_data);
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function __construct(Config $configuration, $placeholders = [])
 {
     parent::__construct($configuration, $placeholders);
     $this->_placeholders[$this->assignType . '_simple::getSku'] = [$this, 'productProvider'];
     $this->_placeholders[$this->assignType . '_simple::getName'] = [$this, 'productProvider'];
     $this->_placeholders[$this->assignType . '_configurable::getSku'] = [$this, 'productProvider'];
     $this->_placeholders[$this->assignType . '_configurable::getName'] = [$this, 'productProvider'];
 }
Ejemplo n.º 9
0
 /**
  * Custom constructor to create Grouped product
  *
  * @param Config $configuration
  * @param array $placeholders
  */
 public function __construct(Config $configuration, $placeholders = [])
 {
     parent::__construct($configuration, $placeholders);
     $this->_placeholders['simple::getName'] = [$this, 'productProvider'];
     $this->_placeholders['virtual::getName'] = [$this, 'productProvider'];
     $this->_placeholders['downloadable::getName'] = [$this, 'productProvider'];
     $this->_placeholders['simple::getProductId'] = [$this, 'productProvider'];
     $this->_placeholders['virtual::getProductId'] = [$this, 'productProvider'];
     $this->_placeholders['downloadable::getProductId'] = [$this, 'productProvider'];
 }
Ejemplo n.º 10
0
 /**
  * @param Product $product
  * @param Product[] $assigned
  * @return void
  */
 protected function assertOnTheFrontEnd(Product $product, array $assigned)
 {
     /** @var Product $simple2 */
     /** @var Product $configurable */
     list($simple2, $configurable) = $assigned;
     //Open up simple1 product page
     $productPage = Factory::getPageFactory()->getCatalogProductView();
     Factory::getClientBrowser()->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $this->assertEquals($product->getName(), $productPage->getViewBlock()->getProductName());
     /** @var \Magento\Catalog\Test\Block\Product\ProductList\Upsell $upsellBlock */
     $upsellBlock = $productPage->getUpsellBlock();
     //Verify upsell simple2 and configurable on Simple1 product page
     $this->assertTrue($upsellBlock->isUpsellProductVisible($simple2->getName()));
     $this->assertTrue($upsellBlock->isUpsellProductVisible($configurable->getName()));
     //Open and verify configurable page
     $upsellBlock->openUpsellProduct($configurable->getName());
     $this->assertEquals($configurable->getName(), $productPage->getViewBlock()->getProductName());
     //Verify upsell simple2 on Configurable product page and open it
     $upsellBlock = $productPage->getUpsellBlock();
     $this->assertTrue($upsellBlock->isUpsellProductVisible($simple2->getName()));
     $upsellBlock->openUpsellProduct($simple2->getName());
     $this->assertEquals($simple2->getName(), $productPage->getViewBlock()->getProductName());
     $this->assertFalse($productPage->getUpsellBlock()->isVisible());
 }
Ejemplo n.º 11
0
 /**
  * Initialize fixture data
  */
 protected function _initData()
 {
     parent::_initData();
     $this->_dataConfig = ['type_id' => 'bundle', 'constraint' => 'Success', 'create_url_params' => ['type' => 'bundle', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID], 'input_prefix' => 'product'];
     $this->_repository = Factory::getRepositoryFactory()->getMagentoBundleBundle($this->_dataConfig, $this->_data);
 }
Ejemplo n.º 12
0
 /**
  * Save new category
  *
  * @param Product $fixture
  * @return void
  */
 public function addNewCategory(Product $fixture)
 {
     $this->openNewCategoryDialog();
     $this->_rootElement->find('input#new_category_name', Locator::SELECTOR_CSS)->setValue($fixture->getNewCategoryName());
     $this->clearCategorySelect();
     $this->selectParentCategory();
     $this->_rootElement->find('div.ui-dialog-buttonset button.action-create')->click();
     $this->waitForElementNotVisible('div.ui-dialog-buttonset button.action-create');
 }
Ejemplo n.º 13
0
 /**
  * Assign an array of products as cross-sells to the passed in $product
  *
  * @param Product $product
  * @param array $crosssellProducts
  * @return void
  */
 private function addCrosssellProducts(Product $product, array $crosssellProducts)
 {
     $crosssellFixture = Factory::getFixtureFactory()->getMagentoCatalogCrosssellProducts();
     $crosssellFixture->setProducts($crosssellProducts);
     $crosssellFixture->switchData('add_crosssell_products');
     //Data
     $productGridPage = Factory::getPageFactory()->getCatalogProductIndex();
     $editProductPage = Factory::getPageFactory()->getCatalogProductEdit();
     //Steps
     $productGridPage->open();
     $productGridPage->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
     $editProductPage->getProductForm()->fill($crosssellFixture);
     $editProductPage->getFormPageActions()->save();
     $editProductPage->getMessagesBlock()->waitSuccessMessage();
 }
Ejemplo n.º 14
0
 /**
  * Init Data
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _initData()
 {
     parent::_initData();
     $this->_dataConfig = ['type_id' => 'configurable', 'constraint' => 'Success', 'create_url_params' => ['type' => Repository::CONFIGURABLE, 'set' => static::DEFAULT_ATTRIBUTE_SET_ID]];
     $data = ['fields' => ['price' => ['value' => '10', 'group' => static::GROUP_PRODUCT_DETAILS], 'tax_class_id' => ['value' => 'Taxable Goods', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select', 'input_value' => '2'], 'weight' => ['value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS], 'product_website_1' => ['value' => 'Yes', 'input_value' => [1], 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'website_ids'], 'configurable_attributes_data' => ['value' => ['0' => ['label' => ['value' => '%attribute_label_1%'], '0' => ['option_label' => ['value' => '%attribute_1_option_label_1%'], 'pricing_value' => ['value' => '1'], 'is_percent' => ['value' => 'No'], 'include' => ['value' => 'Yes']], '1' => ['option_label' => ['value' => '%attribute_1_option_label_2%'], 'pricing_value' => ['value' => '2'], 'is_percent' => ['value' => 'No'], 'include' => ['value' => 'Yes']]]], 'group' => static::GROUP], 'variations-matrix' => ['value' => ['0' => ['configurable_attribute' => ['0' => ['attribute_option' => '%attribute_1_option_label_1%']], 'value' => ['display' => ['value' => 'Yes', 'input' => 'checkbox'], 'name' => ['value' => 'Variation 0-%isolation%'], 'sku' => ['value' => 'Variation 0-%isolation%'], 'qty' => ['value' => '100']]], '1' => ['configurable_attribute' => ['0' => ['attribute_option' => '%attribute_1_option_label_2%']], 'value' => ['display' => ['value' => 'Yes', 'input' => 'checkbox'], 'name' => ['value' => 'Variation 1-%isolation%'], 'sku' => ['value' => 'Variation 1-%isolation%'], 'qty' => ['value' => '200']]]], 'group' => static::GROUP]], 'checkout_data' => ['options' => ['configurable_options' => [['title' => '0', 'value' => '0']], 'qty' => 1], 'special_price' => '10']];
     $this->_data = array_merge_recursive($this->_data, $data);
     $this->_repository = Factory::getRepositoryFactory()->getMagentoConfigurableProductConfigurableProduct($this->_dataConfig, $this->_data);
 }
 /**
  * Assert configurable product on frontend
  *
  * @param Product $product
  * @param ConfigurableProduct $variations
  * @return void
  */
 protected function assertOnFrontend(Product $product, ConfigurableProduct $variations)
 {
     //Pages
     $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
     $categoryPage = Factory::getPageFactory()->getCatalogCategoryView();
     $productPage = Factory::getPageFactory()->getCatalogProductView();
     //Steps
     $frontendHomePage->open();
     $frontendHomePage->getTopmenu()->selectCategoryByName($product->getNewCategoryName());
     //Verification on category product list
     $productListBlock = $categoryPage->getListProductBlock();
     $this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.');
     //Verification on product detail page
     $productViewBlock = $productPage->getViewBlock();
     $productListBlock->openProductViewPage($product->getName());
     $this->assertEquals($product->getName(), $productViewBlock->getProductName(), 'Product name does not correspond to specified.');
     $price = $productViewBlock->getProductPrice();
     $this->assertEquals(number_format($product->getProductPrice(), 2), $price['price_regular_price'], 'Product price does not correspond to specified.');
     $this->assertTrue($productViewBlock->verifyProductOptions($variations), 'Added configurable options are absent.');
 }
Ejemplo n.º 16
0
 /**
  * Click on cross-sell product link
  *
  * @param Product $product
  * @return Element
  */
 public function clickLink($product)
 {
     $this->_rootElement->find(sprintf($this->linkSelector, $product->getName()), Locator::SELECTOR_CSS)->click();
 }
Ejemplo n.º 17
0
 /**
  * Save new category
  *
  * @param Product $fixture
  * @return void
  */
 public function addNewCategory(Product $fixture)
 {
     $this->openTab('product-details');
     $this->openNewCategoryDialog();
     $this->_rootElement->find($this->createCategoryDialog . $this->fieldNewCategoryName, Locator::SELECTOR_XPATH)->setValue($fixture->getNewCategoryName());
     $this->clearCategorySelect();
     $this->selectParentCategory();
     $buttonCreateCategory = $this->createCategoryDialog . $this->createCategoryButton;
     $this->_rootElement->find($buttonCreateCategory, Locator::SELECTOR_XPATH)->click();
     $this->waitForElementNotVisible($buttonCreateCategory, Locator::SELECTOR_XPATH);
 }
 /**
  * Assert configurable product on frontend
  *
  * @param Product $product
  * @param ConfigurableProduct $variations
  * @return void
  */
 protected function assertOnFrontend(Product $product, ConfigurableProduct $variations)
 {
     //Pages
     $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
     $categoryPage = Factory::getPageFactory()->getCatalogCategoryView();
     $productPage = Factory::getPageFactory()->getCatalogProductView();
     //Steps
     $frontendHomePage->open();
     $frontendHomePage->getTopmenu()->selectCategoryByName($product->getNewCategoryName());
     //Verification on category product list
     $productListBlock = $categoryPage->getListProductBlock();
     $this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.');
     //Verification on product detail page
     $productViewBlock = $productPage->getViewBlock();
     $productListBlock->openProductViewPage($product->getName());
     $this->assertEquals($product->getName(), $productViewBlock->getProductName(), 'Product name does not correspond to specified.');
     $price = $productViewBlock->getPriceBlock()->getPrice();
     $this->assertEquals(number_format($product->getProductPrice(), 2), $price, 'Product price does not correspond to specified.');
     $pageOptions = $productViewBlock->getOptions($variations);
     $configurableOptions = [];
     foreach ($pageOptions['configurable_options'] as $attribute) {
         $configurableOption = [];
         foreach ($attribute['options'] as $option) {
             $configurableOption[] = $option['title'];
         }
         $configurableOptions[$attribute['title']] = $configurableOption;
     }
     $this->assertEquals($variations->getConfigurableOptions(), $configurableOptions);
 }
Ejemplo n.º 19
0
 /**
  * Retrieve category name to which the product is assigned
  *
  * @return string
  */
 public function getCategoryName()
 {
     return $this->product->getCategoryName();
 }