Browse Source

Only trigger postDelete hooks when the user was deleted...

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v11.0RC2
Joas Schilling 7 years ago
parent
commit
4d1acfd4ef
No account linked to committer's email address
2 changed files with 8 additions and 7 deletions
  1. 3
    3
      lib/private/User/User.php
  2. 5
    4
      tests/lib/User/UserTest.php

+ 3
- 3
lib/private/User/User.php View File

@@ -218,10 +218,10 @@ class User implements IUser {
$notification = \OC::$server->getNotificationManager()->createNotification();
$notification->setUser($this->uid);
\OC::$server->getNotificationManager()->markProcessed($notification);
}

if ($this->emitter) {
$this->emitter->emit('\OC\User', 'postDelete', array($this));
if ($this->emitter) {
$this->emitter->emit('\OC\User', 'postDelete', array($this));
}
}
return !($result === false);
}

+ 5
- 4
tests/lib/User/UserTest.php View File

@@ -435,16 +435,17 @@ class UserTest extends \Test\TestCase {

public function dataDeleteHooks() {
return [
[true],
[false],
[true, 2],
[false, 1],
];
}

/**
* @dataProvider dataDeleteHooks
* @param bool $result
* @param int $expectedHooks
*/
public function testDeleteHooks($result) {
public function testDeleteHooks($result, $expectedHooks) {
$hooksCalled = 0;
$test = $this;

@@ -521,7 +522,7 @@ class UserTest extends \Test\TestCase {
$this->restoreService('CommentsManager');
$this->restoreService('NotificationManager');

$this->assertEquals(2, $hooksCalled);
$this->assertEquals($expectedHooks, $hooksCalled);
}

public function testGetCloudId() {

Loading…
Cancel
Save