diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-12-03 16:35:57 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2015-12-09 14:34:23 +0100 |
commit | e3dbc3d40ccd9874dadb32b59633cb159afddc48 (patch) | |
tree | 84495c8990e907cde07185c716afba91fc54a517 /tests/lib/comments | |
parent | 2ce2de0ae523e91b90c39a91fdcc975f06a7674a (diff) | |
download | nextcloud-server-e3dbc3d40ccd9874dadb32b59633cb159afddc48.tar.gz nextcloud-server-e3dbc3d40ccd9874dadb32b59633cb159afddc48.zip |
different strategy in cleaning up after user was deleted
we do not listen to deletion hooks anymore, because there is no guarantee that they
will be heard - requires that something fetches the CommentsManager first.
Instead, in the user deletion routine the clean up method will be called directly. Same way
as it happens for files, group memberships, config values.
Diffstat (limited to 'tests/lib/comments')
-rw-r--r-- | tests/lib/comments/fakefactory.php | 19 | ||||
-rw-r--r-- | tests/lib/comments/manager.php | 19 |
2 files changed, 16 insertions, 22 deletions
diff --git a/tests/lib/comments/fakefactory.php b/tests/lib/comments/fakefactory.php index 202b02f6411..cd85a4f34ca 100644 --- a/tests/lib/comments/fakefactory.php +++ b/tests/lib/comments/fakefactory.php @@ -10,13 +10,20 @@ */ class Test_Comments_FakeFactory extends Test\TestCase implements \OCP\Comments\ICommentsManagerFactory { - public function testNothing() { - // If there would not be at least one test, phpunit would scream failure - // So we have one and skip it. - $this->markTestSkipped(); - } - public function getManager() { return $this->getMock('\OCP\Comments\ICommentsManager'); } + + public function testOverwriteDefaultManager() { + $config = \oc::$server->getConfig(); + $defaultManagerFactory = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); + + $managerMock = $this->getMock('\OCP\Comments\ICommentsManager'); + + $config->setSystemValue('comments.managerFactory', 'Test_Comments_FakeFactory'); + $manager = \oc::$server->getCommentsManager(); + $this->assertEquals($managerMock, $manager); + + $config->setSystemValue('comments.managerFactory', $defaultManagerFactory); + } } diff --git a/tests/lib/comments/manager.php b/tests/lib/comments/manager.php index 610dfe51a47..35a1c8a2af5 100644 --- a/tests/lib/comments/manager.php +++ b/tests/lib/comments/manager.php @@ -475,10 +475,10 @@ class Test_Comments_Manager extends Test\TestCase } public function testDeleteReferencesOfActorWithUserManagement() { - $user = \oc::$server->getUserManager()->createUser('xenia', '123456'); + $user = \OC::$server->getUserManager()->createUser('xenia', '123456'); $this->assertTrue($user instanceof \OCP\IUser); - $manager = $this->getManager(); + $manager = \OC::$server->getCommentsManager(); $comment = $manager->create('user', $user->getUID(), 'file', 'file64'); $comment ->setMessage('Most important comment I ever left on the Internet.') @@ -489,7 +489,7 @@ class Test_Comments_Manager extends Test\TestCase $commentID = $comment->getId(); $user->delete(); - $comment =$manager->get($commentID); + $comment = $manager->get($commentID); $this->assertSame($comment->getActorType(), \OCP\Comments\ICommentsManager::DELETED_USER); $this->assertSame($comment->getActorId(), \OCP\Comments\ICommentsManager::DELETED_USER); } @@ -544,17 +544,4 @@ class Test_Comments_Manager extends Test\TestCase $this->assertTrue($wasSuccessful); } - public function testOverwriteDefaultManager() { - $config = \oc::$server->getConfig(); - $defaultManagerFactory = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); - - $managerMock = $this->getMock('\OCP\Comments\ICommentsManager'); - - $config->setSystemValue('comments.managerFactory', 'Test_Comments_FakeFactory'); - $manager = \oc::$server->getCommentsManager(); - $this->assertEquals($managerMock, $manager); - - $config->setSystemValue('comments.managerFactory', $defaultManagerFactory); - } - } |