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
Catalog
Test
Constraint
AssertProductComparePage.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Catalog\Test\Constraint
;
8
9
use Magento\Catalog\Test\Page\Product\CatalogProductCompare;
10
use Magento\Cms\Test\Page\CmsIndex;
11
use Magento\Mtf\Constraint\AbstractConstraint;
12
17
class
AssertProductComparePage
extends
AbstractConstraint
18
{
24
private
$priceFormat = 2;
25
31
protected
$attributeProduct
= [
32
'name'
,
33
'price'
,
34
'sku'
=>
'SKU'
,
35
'description'
=>
'Description'
,
36
'short_description'
=>
'Short Description'
,
37
];
38
54
public
function
processAssert
(
55
array
$products
,
56
CatalogProductCompare $comparePage,
57
CmsIndex $cmsIndex
58
) {
59
$cmsIndex->open();
60
$cmsIndex->getLinksBlock()->openLink(
"Compare Products"
);
61
foreach
(
$products
as $key =>
$product
) {
62
foreach
($this->attributeProduct as $attributeKey =>
$attribute
) {
63
$value
=
$attribute
;
64
$attribute
= is_numeric($attributeKey) ?
$attribute
: $attributeKey;
65
66
$expectedAttributeValue =
$attribute
!=
'price'
67
? (
$product
->hasData(
$attribute
)
68
?
$product
->getData(
$attribute
)
69
:
'N/A'
)
70
: (
$product
->getDataFieldConfig(
'price'
)[
'source'
]->getPriceData() !==
null
71
?
$product
->getDataFieldConfig(
'price'
)[
'source'
]->getPriceData()[
'compare_price'
]
72
: number_format(
$product
->getPrice(), $this->priceFormat));
73
74
$attribute
= is_numeric($attributeKey) ?
'info'
:
'attribute'
;
75
$attribute
= ucfirst(
$attribute
);
76
$actualAttributeValue =
77
$comparePage->getCompareProductsBlock()->{
'getProduct'
.
$attribute
}($key + 1,
$value
);
78
79
\PHPUnit\Framework\Assert::assertEquals(
80
$expectedAttributeValue,
81
$actualAttributeValue,
82
'Product "'
.
$product
->getName() .
'" has "'
.
$attribute
.
'" value different from fixture one.'
83
);
84
}
85
}
86
}
87
93
public
function
toString
()
94
{
95
return
'"Compare Product" page has valid data for all products.'
;
96
}
97
}
Magento\Catalog\Test\Constraint\AssertProductComparePage
Definition:
AssertProductComparePage.php:17
$attribute
$attribute
Definition:
attribute_set_with_image_attribute.php:41
$products
$products
Definition:
products_for_search.php:14
$value
$value
Definition:
gender.phtml:16
Magento\Catalog\Test\Constraint
Definition:
AssertAbsenceDeleteAttributeButton.php:7
Magento\Catalog\Test\Constraint\AssertProductComparePage\processAssert
processAssert(array $products, CatalogProductCompare $comparePage, CmsIndex $cmsIndex)
Definition:
AssertProductComparePage.php:54
Magento\Catalog\Test\Constraint\AssertProductComparePage\$attributeProduct
$attributeProduct
Definition:
AssertProductComparePage.php:31
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
Magento\Catalog\Test\Constraint\AssertProductComparePage\toString
toString()
Definition:
AssertProductComparePage.php:93