Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCategoryUrlDuplicateErrorMessage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryEdit;
10 use Magento\Mtf\Constraint\AbstractConstraint;
12 
16 class AssertCategoryUrlDuplicateErrorMessage 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(
31  CatalogCategoryEdit $productPage,
32  Category $category
33  ) {
34  $actualMessage = $productPage->getMessagesBlock()->getErrorMessage();
35  \PHPUnit\Framework\Assert::assertContains(
36  self::ERROR_MESSAGE_TITLE,
37  $actualMessage,
38  'Wrong error message is displayed.'
39  . "\nExpected: " . self::ERROR_MESSAGE_TITLE
40  . "\nActual:\n" . $actualMessage
41  );
42 
43  \PHPUnit\Framework\Assert::assertContains(
44  $category->getUrlKey(),
45  $actualMessage,
46  'Category url is not present on error message.'
47  . "\nExpected: " . self::ERROR_MESSAGE_TITLE
48  . "\nActual:\n" . $actualMessage
49  );
50  }
51 
57  public function toString()
58  {
59  return 'Category url duplication error on save message is present.';
60  }
61 }