Also send the new account data with the event
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
d25a96d921
commit
bc217cdf87
|
@ -94,7 +94,7 @@ class AccountManager {
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
$this->eventDispatcher->dispatch(
|
$this->eventDispatcher->dispatch(
|
||||||
'OC\AccountManager::userUpdated',
|
'OC\AccountManager::userUpdated',
|
||||||
new GenericEvent($user)
|
new GenericEvent($user, $data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ use OC\Accounts\AccountManager;
|
||||||
use OC\Mail\Mailer;
|
use OC\Mail\Mailer;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,12 +76,11 @@ class AccountsManagerTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataTrueFalse
|
* @dataProvider dataTrueFalse
|
||||||
*
|
|
||||||
* @param bool $userAlreadyExists
|
|
||||||
*/
|
*/
|
||||||
public function testUpdateUser($newData, $oldData, $insertNew, $updateExisitng) {
|
public function testUpdateUser($newData, $oldData, $insertNew, $updateExisitng) {
|
||||||
$accountManager = $this->getInstance(['getUser', 'insertNewUser', 'updateExistingUser']);
|
$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);
|
$accountManager->expects($this->once())->method('getUser')->with($user)->willReturn($oldData);
|
||||||
|
|
||||||
|
@ -102,9 +102,12 @@ class AccountsManagerTest extends TestCase {
|
||||||
} else {
|
} else {
|
||||||
$this->eventDispatcher->expects($this->once())->method('dispatch')
|
$this->eventDispatcher->expects($this->once())->method('dispatch')
|
||||||
->willReturnCallback(
|
->willReturnCallback(
|
||||||
function ($eventName, $event) use ($user) {
|
function ($eventName, $event) use ($user, $newData) {
|
||||||
$this->assertSame('OC\AccountManager::userUpdated', $eventName);
|
$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());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue