Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
functional
tests
app
Magento
Swatches
Test
Constraint
AssertSelectedSwatchOptionsOnProductPage.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Swatches\Test\Constraint
;
7
8
use
Magento\Catalog\Test\Constraint\AssertProductPage
;
9
use Magento\Mtf\Fixture\FixtureInterface;
10
use Magento\Catalog\Test\Page\Product\CatalogProductView;
11
use Magento\Mtf\Client\BrowserInterface;
12
16
class
AssertSelectedSwatchOptionsOnProductPage
extends
AssertProductPage
17
{
21
public
function
processAssert
(
22
BrowserInterface $browser,
23
CatalogProductView $catalogProductView,
24
FixtureInterface
$product
25
) {
26
$this->product =
$product
;
27
$this->productView = $catalogProductView->getProductViewWithSwatchesBlock();
28
29
$this->productView->getSelectedSwatchOptions($this->product);
30
$errors
= $this->
verify
();
31
\PHPUnit\Framework\Assert::assertEmpty(
32
$errors
,
33
"\nFound the following errors:\n"
. implode(
" \n"
,
$errors
)
34
);
35
}
36
42
protected
function
verify
()
43
{
44
$errors
= parent::verify();
45
$errors
[] = $this->
verifySwatches
();
46
47
return
array_filter(
$errors
);
48
}
49
55
protected
function
verifySwatches
()
56
{
57
$actualData = $this->productView->getSelectedSwatchOptions($this->product);
58
$expectedData = $this->
convertCheckoutData
($this->product);
59
$this->
verifyData
($expectedData, $actualData);
60
}
61
68
public
function
convertCheckoutData
(FixtureInterface
$product
)
69
{
70
$out = [];
71
$checkoutData =
$product
->getCheckoutData();
72
$availableAttributes =
$product
->getConfigurableAttributesData();
73
$attributesData
= $availableAttributes[
'attributes_data'
];
74
foreach
($checkoutData[
'options'
][
'configurable_options'
] as
$item
) {
75
$out[
$item
[
'title'
]] =
$attributesData
[
$item
[
'title'
]][
'options'
][
$item
[
'value'
]][
'label'
];
76
}
77
78
return
$out;
79
}
80
86
public
function
toString
()
87
{
88
return
'Swatch attributes displayed as expected on product page'
;
89
}
90
}
Magento\Swatches\Test\Constraint
Definition:
AssertProductPriceWithSelectedSwatchOnCategoryPage.php:6
Magento\Swatches\Test\Constraint\AssertSelectedSwatchOptionsOnProductPage
Definition:
AssertSelectedSwatchOptionsOnProductPage.php:16
Magento\Swatches\Test\Constraint\AssertSelectedSwatchOptionsOnProductPage\verifySwatches
verifySwatches()
Definition:
AssertSelectedSwatchOptionsOnProductPage.php:55
Magento\Swatches\Test\Constraint\AssertSelectedSwatchOptionsOnProductPage\processAssert
processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, FixtureInterface $product)
Definition:
AssertSelectedSwatchOptionsOnProductPage.php:21
$item
$item
Definition:
partial_invoice.php:27
Magento\Mtf\Constraint\AbstractAssertForm\verifyData
verifyData(array $fixtureData, array $formData, $isStrict=false, $isPrepareError=true)
Definition:
AbstractAssertForm.php:46
$attributesData
$attributesData
Definition:
search_attributes.php:13
Magento\Catalog\Test\Constraint\AssertProductPage\$product
$product
Definition:
AssertProductPage.php:32
Magento\Catalog\Test\Constraint\AssertProductPage
Definition:
AssertProductPage.php:18
Magento\Swatches\Test\Constraint\AssertSelectedSwatchOptionsOnProductPage\toString
toString()
Definition:
AssertSelectedSwatchOptionsOnProductPage.php:86
Magento\Swatches\Test\Constraint\AssertSelectedSwatchOptionsOnProductPage\verify
verify()
Definition:
AssertSelectedSwatchOptionsOnProductPage.php:42
Magento\Swatches\Test\Constraint\AssertSelectedSwatchOptionsOnProductPage\convertCheckoutData
convertCheckoutData(FixtureInterface $product)
Definition:
AssertSelectedSwatchOptionsOnProductPage.php:68
$errors
$errors
Definition:
overview.phtml:9