diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserInvalidEmailHostnameMessage.php b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserInvalidEmailHostnameMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..74af3f80cd78f038dcd04a1e76d4a23dd0013fe3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserInvalidEmailHostnameMessage.php @@ -0,0 +1,55 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\User\Test\Constraint; + +use Magento\User\Test\Fixture\User; +use Magento\User\Test\Page\Adminhtml\UserEdit; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertUserInvalidEmailHostnameMessage + */ +class AssertUserInvalidEmailHostnameMessage extends AbstractConstraint +{ + /* tags */ + const SEVERITY = 'low'; + /* end tags */ + + const ERROR_MESSAGE = '\'%s\' is not a valid hostname for email address \'%s\''; + + /** + * Asserts that error message equals to expected message. + * + * @param UserEdit $userEdit + * @param User $user + * @return void + */ + public function processAssert(UserEdit $userEdit, User $user) + { + $email = $user->getEmail(); + $hostname = substr($email, strpos($email, '@')+1); + $expectedMessage = sprintf(self::ERROR_MESSAGE, $hostname, $email); + $actualMessage = $userEdit->getMessagesBlock()->getErrorMessages(); + \PHPUnit_Framework_Assert::assertEquals( + $expectedMessage, + $actualMessage, + 'Wrong error message is displayed.' + . "\nExpected: " . $expectedMessage + . "\nActual: " . $actualMessage + ); + } + + /** + * Returns message if equals to expected message. + * + * @return string + */ + public function toString() + { + return 'Error message about invalid hostname for email on creation user page is correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserEntityTest.xml b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserEntityTest.xml index 98c6794f0dfe3b4934290320024399493b1188ab..cac4f73a49c5f3ef40d607580ae439c728ed6ce2 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserEntityTest.xml @@ -88,7 +88,7 @@ <data name="user/data/is_active" xsi:type="string">Active</data> <data name="isDuplicated" xsi:type="string">-</data> <data name="user/data/current_password" xsi:type="string">%current_password%</data> - <constraint name="Magento\User\Test\Constraint\AssertUserInvalidEmailMessage"/> + <constraint name="Magento\User\Test\Constraint\AssertUserInvalidEmailHostnameMessage"/> </variation> </testCase> </config>