Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCmsBlockOnCategoryPage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
11 use Magento\Cms\Test\Page\CmsIndex;
12 use Magento\Mtf\Constraint\AbstractConstraint;
13 use Magento\Mtf\Fixture\FixtureFactory;
14 
18 class AssertCmsBlockOnCategoryPage extends AbstractConstraint
19 {
30  public function processAssert(
31  CmsIndex $cmsIndex,
32  CmsBlock $cmsBlock,
33  CatalogCategoryView $catalogCategoryView,
34  FixtureFactory $fixtureFactory
35  ) {
36  $category = $fixtureFactory->createByCode(
37  'category',
38  [
39  'dataset' => 'default_subcategory',
40  'data' => [
41  'display_mode' => 'Static block and products',
42  'landing_page' => $cmsBlock->getTitle(),
43  ]
44  ]
45  );
46  $category->persist();
47 
48  $cmsIndex->open();
49  $cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
50  $categoryViewContent = $catalogCategoryView->getViewBlock()->getContent();
51 
52  \PHPUnit\Framework\Assert::assertEquals(
53  $cmsBlock->getContent(),
54  $categoryViewContent,
55  'Wrong block content on category is displayed.'
56  );
57  }
58 
64  public function toString()
65  {
66  return 'CMS block description is present on Category page (frontend).';
67  }
68 }
processAssert(CmsIndex $cmsIndex, CmsBlock $cmsBlock, CatalogCategoryView $catalogCategoryView, FixtureFactory $fixtureFactory)