]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only trigger postDelete hooks when the user was deleted... 1695/head
authorJoas Schilling <coding@schilljs.com>
Thu, 29 Sep 2016 13:05:47 +0000 (15:05 +0200)
committerJoas Schilling <coding@schilljs.com>
Tue, 11 Oct 2016 08:45:39 +0000 (10:45 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/User/User.php
tests/lib/User/UserTest.php

index 7859db23b6b817ff59aa185fa44543e60aa4ea20..decd32ac82e00229fc402134bdfb1b2beeb7a602 100644 (file)
@@ -216,10 +216,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);
        }
index 69bab0b659b6f6c9d4acc4e7779efae4413f6cd4..d72d7af7c3a802b7e49ae5ead20b45888f27e381 100644 (file)
@@ -430,16 +430,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;
 
@@ -516,7 +517,7 @@ class UserTest extends \Test\TestCase {
                $this->restoreService('CommentsManager');
                $this->restoreService('NotificationManager');
 
-               $this->assertEquals(2, $hooksCalled);
+               $this->assertEquals($expectedHooks, $hooksCalled);
        }
 
        public function testGetCloudId() {