11 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
12 use Magento\Mtf\Client\BrowserInterface;
13 use Magento\Mtf\Constraint\AbstractConstraint;
28 'Static block and products' 62 CatalogCategoryView $categoryView,
67 $this->categoryViewPage = $categoryView;
71 $diff = array_merge($diff, $this->verifyContent($categoryData));
74 \PHPUnit\Framework\Assert::assertEmpty(
76 "Category settings on Storefront page are different.\n" . implode(
' ', $diff)
88 if (isset(
$data[
'id'])) {
102 $categoryUrlKey = [];
104 $categoryUrlKey[] =
$category->hasData(
'url_key')
106 : trim(strtolower(preg_replace(
'#[^0-9a-z%]+#i',
'-',
$category->getName())),
'-');
108 $category =
$category->getDataFieldConfig(
'parent_id')[
'source']->getParentCategory();
114 return $_ENV[
'app_frontend_url'] . implode(
'/', array_reverse($categoryUrlKey)) .
'.html';
129 if (isset($categoryData[
'include_in_menu']) && $categoryData[
'include_in_menu'] ==
'Yes') {
130 if (!$this->categoryViewPage->getTopmenu()->isCategoryVisible($categoryData[
'name'])) {
131 $errorMessage[] =
'Category is not visible in the navigation pane.';
134 if (isset($categoryData[
'include_in_menu']) && $categoryData[
'include_in_menu'] ==
'No') {
135 if ($this->categoryViewPage->getTopmenu()->isCategoryVisible($categoryData[
'name'])) {
136 $errorMessage[] =
'Category is visible in the navigation pane.';
140 if (isset($categoryData[
'name'])) {
141 $title = $this->categoryViewPage->getTitleBlock()->getTitle();
142 if ($categoryData[
'name'] !=
$title) {
143 $errorMessage[] =
'Wrong category name.' 144 .
"\nExpected: " . $categoryData[
'name']
149 return $errorMessage;
160 protected function verifyContent(array $categoryData)
164 if (!$this->categoryViewPage->getViewBlock()->isVisible()) {
166 'Category Content is not visible.' 167 .
"Skipped verifying Content settings for category {$categoryData['name']}.";
168 return $errorMessage;
171 if (isset($categoryData[
'description'])) {
172 $description = $this->categoryViewPage->getViewBlock()->getDescription();
174 $errorMessage[] =
'Wrong category description.' 175 .
"\nExpected: " . $categoryData[
'description']
180 if (isset($categoryData[
'landing_page'])
181 && isset($categoryData[
'display_mode'])
182 && in_array($categoryData[
'display_mode'], $this->visibleCmsBlockMode)
185 $sourceLandingPage = $this->category->getDataFieldConfig(
'landing_page')[
'source'];
186 $fixtureContent = $sourceLandingPage->getCmsBlock()->getContent();
187 $pageContent = $this->categoryViewPage->getViewBlock()->getContent();
189 if ($fixtureContent != $pageContent) {
190 $errorMessage[] =
'Wrong category landing page content.' 191 .
"\nExpected: " . $fixtureContent
192 .
"\nActual: " . $pageContent;
196 return $errorMessage;
213 if (isset($categoryData[
'default_sort_by'])) {
214 $expected = $categoryData[
'default_sort_by'];
215 $actual = $this->categoryViewPage->getTopToolbar()->getSelectSortType();
216 if ($expected != $actual) {
217 $errorMessage[] =
'Wrong sorting type.' 218 .
"\nExpected: " . $expected
219 .
"\nActual: " . $actual;
223 if (isset($categoryData[
'available_sort_by'])) {
224 $availableSortType = array_filter(
225 $categoryData[
'available_sort_by'],
230 if ($availableSortType) {
231 $expected = array_values($availableSortType);
232 $actual = $this->categoryViewPage->getTopToolbar()->getSortType();
233 if ($expected != $actual) {
234 $errorMessage[] =
'Wrong available sorting type.' 235 .
"\nExpected: " . implode(PHP_EOL, $expected)
236 .
"\nActual: " . implode(PHP_EOL, $actual);
243 return $errorMessage;
259 if ($categoryUrl != $this->browser->getUrl()) {
260 $errorMessage[] =
'Wrong page URL.' 261 .
"\nExpected: " . $categoryUrl
262 .
"\nActual: " . $this->browser->getUrl();
265 if (isset($categoryData[
'meta_title'])) {
266 $actual = $this->browser->getTitle();
267 if ($categoryData[
'meta_title'] != $actual) {
268 $errorMessage[] =
'Wrong page title.' 269 .
"\nExpected: " . $categoryData[
'meta_title']
270 .
"\nActual: " . $actual;
274 return $errorMessage;
284 return 'Category data on category page equals to passed from fixture.';
getCategoryUrl(Category $category)
verifyGeneralInformation(array $categoryData)
verifySearchEngineOptimization(array $categoryData)
processAssert(Category $category, CatalogCategoryView $categoryView, BrowserInterface $browser)
prepareFixtureData(array $data)
verifyDisplaySettings(array $categoryData)