diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-12-02 16:54:17 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-12-02 18:07:08 +0100 |
commit | f25ad2e404ab70c2b62ebc43212293a6d6ac014f (patch) | |
tree | db71f4f7b0afd310494b95d92ac3c600a13b48be /tests | |
parent | bc597b184306aa39a48963cb9a8015354c6e2ce2 (diff) | |
download | nextcloud-server-f25ad2e404ab70c2b62ebc43212293a6d6ac014f.tar.gz nextcloud-server-f25ad2e404ab70c2b62ebc43212293a6d6ac014f.zip |
make sure that we only update the email address if it really changed
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Settings/Controller/UsersControllerTest.php | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/Settings/Controller/UsersControllerTest.php b/tests/Settings/Controller/UsersControllerTest.php index 69082a7929c..b85667740f7 100644 --- a/tests/Settings/Controller/UsersControllerTest.php +++ b/tests/Settings/Controller/UsersControllerTest.php @@ -2107,20 +2107,22 @@ class UsersControllerTest extends \Test\TestCase { $user->method('getEMailAddress')->willReturn($oldEmailAddress); $user->method('canChangeDisplayName')->willReturn(true); - if ($data[AccountManager::PROPERTY_EMAIL]['value'] !== $oldEmailAddress) { + if ($data[AccountManager::PROPERTY_EMAIL]['value'] === $oldEmailAddress || + $oldEmailAddress === null && $data[AccountManager::PROPERTY_EMAIL]['value'] === '') { + $user->expects($this->never())->method('setEMailAddress'); + } else { $user->expects($this->once())->method('setEMailAddress') ->with($data[AccountManager::PROPERTY_EMAIL]['value']) ->willReturn(true); - } else { - $user->expects($this->never())->method('setEMailAddress'); } - if ($data[AccountManager::PROPERTY_DISPLAYNAME]['value'] !== $oldDisplayName) { + if ($data[AccountManager::PROPERTY_DISPLAYNAME]['value'] === $oldDisplayName || + $oldDisplayName === null && $data[AccountManager::PROPERTY_DISPLAYNAME]['value'] === '') { + $user->expects($this->never())->method('setDisplayName'); + } else { $user->expects($this->once())->method('setDisplayName') ->with($data[AccountManager::PROPERTY_DISPLAYNAME]['value']) ->willReturn(true); - } else { - $user->expects($this->never())->method('setDisplayName'); } $this->accountManager->expects($this->once())->method('updateUser') @@ -2162,7 +2164,23 @@ class UsersControllerTest extends \Test\TestCase { ], 'john@example.com', 'john New doe' - ] + ], + [ + [ + AccountManager::PROPERTY_EMAIL => ['value' => ''], + AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + ], + null, + 'john New doe' + ], + [ + [ + AccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + ], + 'john@example.com', + null + ], ]; } @@ -2274,6 +2292,7 @@ class UsersControllerTest extends \Test\TestCase { ->with( $this->equalTo($mailAddress) ); + $user->method('getEMailAddress')->willReturn('oldEmailAddress'); $this->mailer ->expects($this->any()) ->method('validateMailAddress') |