Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCmsPageDuplicateErrorMessage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Cms\Test\Page\Adminhtml\CmsPageIndex;
10 use Magento\Mtf\Constraint\AbstractConstraint;
12 
16 class AssertCmsPageDuplicateErrorMessage extends AbstractConstraint
17 {
21  const ERROR_MESSAGE_TITLE = 'The value specified in the URL Key field would generate a URL that already exists.';
22 
30  public function processAssert(CmsPageIndex $cmsIndex, CmsPage $cmsPage)
31  {
32  $actualMessage = $cmsIndex->getMessagesBlock()->getErrorMessage();
33 
34  \PHPUnit\Framework\Assert::assertContains(
35  self::ERROR_MESSAGE_TITLE,
36  $actualMessage,
37  'Wrong error message is displayed.'
38  . "\nExpected: " . self::ERROR_MESSAGE_TITLE
39  . "\nActual:\n" . $actualMessage
40  );
41 
42  \PHPUnit\Framework\Assert::assertContains(
43  $cmsPage->getIdentifier(),
44  $actualMessage,
45  'CMS page url is not present on error message.'
46  . "\nExpected: " . self::ERROR_MESSAGE_TITLE
47  . "\nActual:\n" . $actualMessage
48  );
49  }
50 
56  public function toString()
57  {
58  return 'Assert that page with duplicated identifier has not been created.';
59  }
60 }