10 use Magento\Catalog\Test\Page\Product\CatalogProductView;
12 use Magento\Mtf\Client\Element\SimpleElement;
13 use Magento\Mtf\Block\Block;
14 use Magento\Mtf\Client\Locator;
15 use Magento\Mtf\Fixture\FixtureInterface;
16 use Magento\Mtf\Fixture\InjectableFixture;
57 protected $required =
'./self::*[contains(@class,"required")]';
71 protected $optionLabel =
'.//div[@class="control"]//label[.//*[@class="product-name"]]';
108 public function addToCart(BundleProduct $product, CatalogProductView $catalogProductView)
110 $catalogProductView->getViewBlock()->fillOptions(
$product);
111 $catalogProductView->getViewBlock()->clickAddToCart();
121 public function getOptions(FixtureInterface $product)
125 $bundleSelections =
$product->getBundleSelections();
126 $bundleOptions = isset($bundleSelections[
'bundle_options']) ? $bundleSelections[
'bundle_options'] : [];
133 if (!isset($listFormOptions[
$title])) {
134 throw new \Exception(
"Can't find option: \"{$title}\"");
136 $this->optionIndex =
$index;
175 $optionElement = $this->_rootElement->find(sprintf($this->optionElement,
$count), Locator::SELECTOR_XPATH);
181 $optionElement = $this->_rootElement->find(sprintf($this->optionElement,
$count), Locator::SELECTOR_XPATH);
194 if ($this->isOneProductInStock($this->product)) {
195 return [
'options' => $this->getFlatTextData()];
197 $select =
$option->find($this->selectOption, Locator::SELECTOR_XPATH,
'select');
210 $multiselect =
$option->find($this->selectOption, Locator::SELECTOR_XPATH,
'multiselect');
214 $option[
'title'] = trim(preg_replace(
'/^[\d]+ x/',
'',
$option[
'title']));
230 $optionLabels =
$option->getElements($this->optionLabel, Locator::SELECTOR_XPATH);
238 return [
'options' => $listOptions];
252 $option[
'title'] = trim(preg_replace(
'/^[\d]+ x/',
'',
$option[
'title']));
276 $option[
'selected'] = $selected;
283 return [
'options' => $listOptions];
294 preg_match(
'`^(.*?)\+ ?\$(\d.*?)$`sim', $optionText, $match);
295 $optionPrice = isset($match[2]) ? str_replace(
',',
'', $match[2]) : 0;
296 $optionTitle = isset($match[1]) ? trim($match[1]) : $optionText;
299 'title' => $optionTitle,
300 'price' => $optionPrice
313 $selector = sprintf($this->bundleOptionBlock,
$option[
'title']);
314 $useDefault = isset(
$option[
'use_default']) && strtolower(
$option[
'use_default']) ==
'true' ? true :
false;
317 $optionBlock = $this->blockFactory->create(
318 'Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option\\' 320 [
'element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)]
322 $optionBlock->fillOption(
$option[
'value']);
335 $trimmedOptionType = preg_replace(
'/[^a-zA-Z]/',
'', $optionType);
336 return ucfirst(strtolower($trimmedOptionType));
345 private function isOneProductInStock(BundleProduct
$products)
350 $status =
$product->getData()[
'quantity_and_stock_status'][
'is_in_stock'];
366 private function getFlatTextData()
368 $productPrice = $this->_rootElement->find($this->assignedProductPrice)->getText();
369 $productPrice = preg_replace(
"/[^0-9.,]/",
'', $productPrice);
370 $productName = $this->_rootElement->find($this->assignedProductName)->getText();
373 'price' => number_format($productPrice, 2)
getCheckboxData(SimpleElement $option)
optionNameConvert($optionType)
getRadiobuttonsData(SimpleElement $option)
getDropdownData(SimpleElement $option)
isOptionVisible($optionTitle)
getOptions(FixtureInterface $product=null)
getMultipleselectData(SimpleElement $option)
getSelectOptionsData(SimpleElement $element, $firstOption=1)
addToCart(BundleProduct $product, CatalogProductView $catalogProductView)
parseOptionText($optionText)