Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCmsBlockNotOnCategoryPage.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;
15 
19 class AssertCmsBlockNotOnCategoryPage extends AbstractConstraint
20 {
32  public function processAssert(
33  CmsIndex $cmsIndex,
34  CmsBlock $cmsBlock,
35  CatalogCategoryView $catalogCategoryView,
36  FixtureFactory $fixtureFactory,
37  Category $category = null
38  ) {
39  if ($category === null) {
40  $category = $fixtureFactory->createByCode(
41  'category',
42  [
43  'dataset' => 'default_subcategory',
44  'data' => [
45  'display_mode' => 'Static block and products',
46  'landing_page' => $cmsBlock->getTitle(),
47  ]
48  ]
49  );
50  $category->persist();
51  }
52 
53  $cmsIndex->open();
54  $cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
55  $categoryViewContent = $catalogCategoryView->getViewBlock()->getContent();
56 
57  \PHPUnit\Framework\Assert::assertNotEquals(
58  $cmsBlock->getContent(),
59  $categoryViewContent,
60  'Wrong block content on category is displayed.'
61  );
62  }
63 
69  public function toString()
70  {
71  return 'CMS block description is absent on Category page (frontend).';
72  }
73 }
processAssert(CmsIndex $cmsIndex, CmsBlock $cmsBlock, CatalogCategoryView $catalogCategoryView, FixtureFactory $fixtureFactory, Category $category=null)