Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2016-11-23 23:19:06 +0300
committerBjoern Schiessle <bjoern@schiessle.org>2016-11-25 12:26:47 +0300
commit3fc75073b80a3ffedbcd127e9e75edf567f245a5 (patch)
treeee318005b5c38f1b8ae2e1562371d505a760ffb5 /tests/lib/Accounts
parent546989959c11bc773461cdd8ff0233e3f54255e0 (diff)
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/Accounts')
-rw-r--r--tests/lib/Accounts/AccountsManagerTest.php39
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]
];
}