/** * Initialize fixture data * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _initData() { $this->_data['checkout'] = ['prices' => ['price_from' => 110, 'price_to' => 120], 'selection' => [0]]; parent::_initData(); $this->_data['fields'] = array_merge_recursive($this->_data['fields'], ['sku_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'price_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'price' => ['value' => 100, 'group' => static::GROUP_PRODUCT_DETAILS], 'tax_class_id' => ['value' => 'Taxable Goods', 'input_value' => '2', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'weight_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], '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'], 'shipment_type' => ['value' => 'Separately', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'bundle_selections' => ['value' => ['bundle_options' => [['title' => 'Drop-down Option', 'type' => 'Drop-down', 'required' => 'Yes', 'assigned_products' => [['search_data' => ['name' => '%item1_simple1::getName%'], 'data' => ['selection_price_value' => 10, 'selection_price_type' => 'Fixed', 'selection_qty' => 1, 'product_id' => '%item1_simple1::getProductId%']], ['search_data' => ['name' => '%item1_virtual2::getName%'], 'data' => ['selection_price_value' => 20, 'selection_price_type' => 'Percent', 'selection_qty' => 1, 'product_id' => '%item1_virtual2::getProductId%']]]]]], 'group' => static::GROUP]]); $this->_repository = Factory::getRepositoryFactory()->getMagentoBundleBundle($this->_dataConfig, $this->_data); }
/** * Initialize fixture data */ protected function _initData() { $this->_data['checkout'] = array('prices' => array('price_from' => 10, 'price_to' => 15), 'selection' => array('bundle_item_0' => 'assigned_product_0')); parent::_initData(); $this->_data['fields'] = array_merge_recursive($this->_data['fields'], array('sku_type' => array('value' => 'Dynamic', 'input_value' => '0', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'), 'price_type' => array('value' => 'Dynamic', 'input_value' => '0', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'), 'weight_type' => array('value' => 'Dynamic', 'input_value' => '0', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'), 'product_website_1' => array('value' => 'Yes', 'input_value' => array(1), 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'website_ids'), 'shipment_type' => array('value' => 'Separately', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'), 'bundle_selections' => array('value' => array('bundle_options' => array('bundle_item_0' => array('title' => 'Drop-down Option', 'type' => 'Drop-down', 'required' => 'Yes', 'assigned_products' => array('assigned_product_0' => array('search_data' => array('name' => '%item1_simple1::getName%'), 'data' => array('selection_qty' => 1, 'product_id' => '%item1_simple1::getProductId%')), 'assigned_product_1' => array('search_data' => array('name' => '%item1_virtual2::getName%'), 'data' => array('selection_qty' => 1, 'product_id' => '%item1_virtual2::getProductId%')))))), 'group' => static::GROUP))); $this->_repository = Factory::getRepositoryFactory()->getMagentoBundleBundle($this->_dataConfig, $this->_data); }
/** * Checking the product on the category page * * @param Bundle $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()), 'Product "' . $product->getName() . '" is absent on category page'); $productListBlock->openProductViewPage($product->getName()); //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertSame($product->getName(), $productViewBlock->getProductName()); $this->assertEquals($product->getProductPrice(), ['price_from' => $productViewBlock->getPriceBlock()->getPriceFrom(), 'price_to' => $productViewBlock->getPriceBlock()->getPriceTo()]); $expectedOptions = $product->getBundleOptions(); $actualOptions = $productViewBlock->getOptions($product)['bundle_options']; foreach ($actualOptions as $key => $actualOption) { $this->assertContains($expectedOptions[$key]['title'], $actualOption); } }
/** * Check the product on the category page * * @param Bundle $product * @param string $categoryName * @return void */ protected function assertOnCategory($product, $categoryName) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); //Steps $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($categoryName); //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->assertSame($product->getName(), $productViewBlock->getProductName()); $this->assertEquals($product->getProductPrice(), ['price_from' => $productViewBlock->getPriceBlock()->getPriceFrom(), 'price_to' => $productViewBlock->getPriceBlock()->getPriceTo()]); }
/** * Checking the product on the category page * * @param Bundle $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->assertSame($product->getName(), $productViewBlock->getProductName()); $this->assertEquals($product->getProductPrice(), $productViewBlock->getProductPrice()); // @TODO: add click on "Customize and Add To Cart" button and assert options count $productOptionsBlock = $productPage->getCustomOptionsBlock(); $actualOptions = $productOptionsBlock->getOptions(); $expectedOptions = $product->getBundleOptions(); foreach ($actualOptions as $optionType => $actualOption) { $this->assertContains($expectedOptions[$optionType], $actualOption); } }