summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-04-10 11:14:39 +0200
committerGitHub <noreply@github.com>2017-04-10 11:14:39 +0200
commit87bca3841323a25b4be8faa17b812aadb421ed36 (patch)
treecca1b3a6d62839401fb6e9bd1b74413234e988cb
parent235563f0a0481209f2e5d0303afe0b4db36bfcb6 (diff)
parentbc217cdf874238e9414810d5cd009d2d496e9ac5 (diff)
downloadnextcloud-server-87bca3841323a25b4be8faa17b812aadb421ed36.tar.gz
nextcloud-server-87bca3841323a25b4be8faa17b812aadb421ed36.zip
Merge pull request #4271 from nextcloud/also-send-the-new-data-with-the-event
Also send the new account data with the event
-rw-r--r--lib/private/Accounts/AccountManager.php2
-rw-r--r--tests/lib/Accounts/AccountsManagerTest.php13
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php
index 3701421a20f..2eb518d4f04 100644
--- a/lib/private/Accounts/AccountManager.php
+++ b/lib/private/Accounts/AccountManager.php
@@ -94,7 +94,7 @@ class AccountManager {
if ($updated) {
$this->eventDispatcher->dispatch(
'OC\AccountManager::userUpdated',
- new GenericEvent($user)
+ new GenericEvent($user, $data)
);
}
}
diff --git a/tests/lib/Accounts/AccountsManagerTest.php b/tests/lib/Accounts/AccountsManagerTest.php
index 60811140e72..c0e20164908 100644
--- a/tests/lib/Accounts/AccountsManagerTest.php
+++ b/tests/lib/Accounts/AccountsManagerTest.php
@@ -27,6 +27,7 @@ use OC\Accounts\AccountManager;
use OC\Mail\Mailer;
use OCP\IUser;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\GenericEvent;
use Test\TestCase;
/**
@@ -75,12 +76,11 @@ class AccountsManagerTest extends TestCase {
/**
* @dataProvider dataTrueFalse
- *
- * @param bool $userAlreadyExists
*/
public function testUpdateUser($newData, $oldData, $insertNew, $updateExisitng) {
$accountManager = $this->getInstance(['getUser', 'insertNewUser', 'updateExistingUser']);
- $user = $this->getMockBuilder('OCP\IUser')->getMock();
+ /** @var IUser $user */
+ $user = $this->createMock(IUser::class);
$accountManager->expects($this->once())->method('getUser')->with($user)->willReturn($oldData);
@@ -102,9 +102,12 @@ class AccountsManagerTest extends TestCase {
} else {
$this->eventDispatcher->expects($this->once())->method('dispatch')
->willReturnCallback(
- function ($eventName, $event) use ($user) {
+ function ($eventName, $event) use ($user, $newData) {
$this->assertSame('OC\AccountManager::userUpdated', $eventName);
- $this->assertInstanceOf('Symfony\Component\EventDispatcher\GenericEvent', $event);
+ $this->assertInstanceOf(GenericEvent::class, $event);
+ /** @var GenericEvent $event */
+ $this->assertSame($user, $event->getSubject());
+ $this->assertSame($newData, $event->getArguments());
}
);
}