From 2716c9d296a7051900eb1146a820c6b89dc8c71e Mon Sep 17 00:00:00 2001
From: Cari Spruiell <cspruiell@ebay.com>
Date: Fri, 19 Jun 2015 16:50:49 -0500
Subject: [PATCH] MAGETWO-37579: User invalid email message not displayed

 - modified functional test to expect the new error message
---
 .../AssertUserInvalidEmailHostnameMessage.php | 55 +++++++++++++++++++
 .../TestCase/CreateAdminUserEntityTest.xml    |  2 +-
 2 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserInvalidEmailHostnameMessage.php

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 00000000000..74af3f80cd7
--- /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 98c6794f0df..cac4f73a49c 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>
-- 
GitLab