From 1bb2a3ca7480fc397d0bb09b7e473c8244ef55b5 Mon Sep 17 00:00:00 2001
From: Arkadii Chyzhov <achyzhov@ebay.com>
Date: Thu, 19 Mar 2015 23:23:55 +0200
Subject: [PATCH] MAGETWO-6761: Incorrect Url when create admin user with name
 or email that already exist

- test for the bugfix
---
 .../User/Controller/Adminhtml/UserTest.php    | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php
index 0fa5bfb6712..f7de99380e8 100644
--- a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php
+++ b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php
@@ -95,6 +95,32 @@ class UserTest extends \Magento\Backend\Utility\Controller
         $this->assertRedirect($this->stringContains('backend/admin/user/index/'));
     }
 
+    /**
+     * @magentoDbIsolation enabled
+     * @magentoDataFixture Magento/User/_files/user_with_role.php
+     */
+    public function testSaveActionDuplicateUser()
+    {
+        $this->getRequest()->setPostValue(
+            [
+                'username' => 'adminUser',
+                'email' => 'adminUser@example.com',
+                'firstname' => 'John',
+                'lastname' => 'Doe',
+                'password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
+                'password_confirmation' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
+                \Magento\User\Block\User\Edit\Tab\Main::CURRENT_USER_PASSWORD_FIELD => Bootstrap::ADMIN_PASSWORD,
+            ]
+        );
+        $this->dispatch('backend/admin/user/save/active_tab/main_section');
+        $this->assertSessionMessages(
+            $this->equalTo(['A user with the same user name or email already exists.']),
+            \Magento\Framework\Message\MessageInterface::TYPE_ERROR
+        );
+        $this->assertRedirect($this->stringContains('backend/admin/user/edit/'));
+        $this->assertRedirect($this->matchesRegularExpression('/^((?!active_tab).)*$/'));
+    }
+
     /**
      * @magentoDbIsolation enabled
      * @dataProvider resetPasswordDataProvider
-- 
GitLab