diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-23 21:19:06 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-25 10:26:47 +0100 |
commit | 3fc75073b80a3ffedbcd127e9e75edf567f245a5 (patch) | |
tree | ee318005b5c38f1b8ae2e1562371d505a760ffb5 /tests/lib | |
parent | 546989959c11bc773461cdd8ff0233e3f54255e0 (diff) | |
download | nextcloud-server-3fc75073b80a3ffedbcd127e9e75edf567f245a5.tar.gz nextcloud-server-3fc75073b80a3ffedbcd127e9e75edf567f245a5.zip |
update accounts table if email address or display name changes from outside
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/Accounts/AccountsManagerTest.php | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/tests/lib/Accounts/AccountsManagerTest.php b/tests/lib/Accounts/AccountsManagerTest.php index de88fbcab97..60811140e72 100644 --- a/tests/lib/Accounts/AccountsManagerTest.php +++ b/tests/lib/Accounts/AccountsManagerTest.php @@ -78,36 +78,45 @@ class AccountsManagerTest extends TestCase { * * @param bool $userAlreadyExists */ - public function testUpdateUser($userAlreadyExists) { + public function testUpdateUser($newData, $oldData, $insertNew, $updateExisitng) { $accountManager = $this->getInstance(['getUser', 'insertNewUser', 'updateExistingUser']); $user = $this->getMockBuilder('OCP\IUser')->getMock(); - $accountManager->expects($this->once())->method('getUser')->with($user)->willReturn($userAlreadyExists); + $accountManager->expects($this->once())->method('getUser')->with($user)->willReturn($oldData); - if ($userAlreadyExists) { + if ($updateExisitng) { $accountManager->expects($this->once())->method('updateExistingUser') - ->with($user, 'data'); + ->with($user, $newData); $accountManager->expects($this->never())->method('insertNewUser'); - } else { + } + if ($insertNew) { $accountManager->expects($this->once())->method('insertNewUser') - ->with($user, 'data'); + ->with($user, $newData); $accountManager->expects($this->never())->method('updateExistingUser'); } - $this->eventDispatcher->expects($this->once())->method('dispatch') - ->willReturnCallback(function($eventName, $event) use ($user) { - $this->assertSame('OC\AccountManager::userUpdated', $eventName); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\GenericEvent', $event); - } - ); + if (!$insertNew && !$updateExisitng) { + $accountManager->expects($this->never())->method('updateExistingUser'); + $accountManager->expects($this->never())->method('insertNewUser'); + $this->eventDispatcher->expects($this->never())->method('dispatch'); + } else { + $this->eventDispatcher->expects($this->once())->method('dispatch') + ->willReturnCallback( + function ($eventName, $event) use ($user) { + $this->assertSame('OC\AccountManager::userUpdated', $eventName); + $this->assertInstanceOf('Symfony\Component\EventDispatcher\GenericEvent', $event); + } + ); + } - $accountManager->updateUser($user, 'data'); + $accountManager->updateUser($user, $newData); } public function dataTrueFalse() { return [ - [true], - [false] + [['newData'], ['oldData'], false, true], + [['newData'], [], true, false], + [['oldData'], ['oldData'], false, false] ]; } |