]> source.dussan.org Git - nextcloud-server.git/commitdiff
Removed deprecated function OC_User::deleteUser
authorRoeland Jago Douma <rullzer@owncloud.com>
Thu, 17 Dec 2015 14:59:23 +0000 (15:59 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Thu, 17 Dec 2015 15:18:40 +0000 (16:18 +0100)
Replaced with proper OCP calls

17 files changed:
apps/encryption/tests/lib/MigrationTest.php
apps/files/tests/service/tagservice.php
apps/files_sharing/tests/controller/sharecontroller.php
apps/files_sharing/tests/testcase.php
apps/files_trashbin/tests/storage.php
apps/files_trashbin/tests/trashbin.php
apps/files_versions/tests/versions.php
lib/private/user.php
tests/lib/files/cache/cache.php
tests/lib/files/cache/updaterlegacy.php
tests/lib/files/filesystem.php
tests/lib/files/objectstore/swift.php
tests/lib/files/storage/homestoragequota.php
tests/lib/helperstorage.php
tests/lib/security/certificatemanager.php
tests/lib/share/share.php
tests/lib/user.php

index ec1dccb87b80616f2652b0bb728760faffbd91eb..6df72ac1bf618fdfc553fc98ccfc4acb0b780d79 100644 (file)
@@ -49,9 +49,12 @@ class MigrationTest extends \Test\TestCase {
        }
 
        public static function tearDownAfterClass() {
-               \OC_User::deleteUser(self::TEST_ENCRYPTION_MIGRATION_USER1);
-               \OC_User::deleteUser(self::TEST_ENCRYPTION_MIGRATION_USER2);
-               \OC_User::deleteUser(self::TEST_ENCRYPTION_MIGRATION_USER3);
+               $user = \OC::$server->getUserManager()->get(self::TEST_ENCRYPTION_MIGRATION_USER1);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get(self::TEST_ENCRYPTION_MIGRATION_USER2);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get(self::TEST_ENCRYPTION_MIGRATION_USER3);
+               if ($user !== null) { $user->delete(); }
                parent::tearDownAfterClass();
        }
 
index a34bd05afcc5dcf04a49c41723dda08c2afe8cee..b93dedd0efdccd4596bb6d22d05db3c62b1b8336 100644 (file)
@@ -82,7 +82,8 @@ class TagServiceTest extends \Test\TestCase {
 
        protected function tearDown() {
                \OC_User::setUserId('');
-               \OC_User::deleteUser($this->user);
+               $user = \OC::$server->getUserManager()->get($this->user);
+               if ($user !== null) { $user->delete(); }
        }
 
        public function testUpdateFileTags() {
index d165151b87f9556a45deb21f1d567572710a8fa9..398538f09438b09bd577a662d82e22fd6a56a815 100644 (file)
@@ -98,7 +98,8 @@ class ShareControllerTest extends \Test\TestCase {
                \OC_Util::tearDownFS();
                \OC_User::setUserId('');
                Filesystem::tearDown();
-               \OC_User::deleteUser($this->user);
+               $user = \OC::$server->getUserManager()->get($this->user);
+               if ($user !== null) { $user->delete(); }
                \OC_User::setIncognitoMode(false);
 
                \OC::$server->getSession()->set('public_link_authenticated', '');
index cc82fc3d949e93e7738bef0df2bc18b212e9b054..c4037c7c42e50bc9cd316e6a4776f682ec73c894 100644 (file)
@@ -117,9 +117,12 @@ abstract class TestCase extends \Test\TestCase {
 
        public static function tearDownAfterClass() {
                // cleanup users
-               \OC_User::deleteUser(self::TEST_FILES_SHARING_API_USER1);
-               \OC_User::deleteUser(self::TEST_FILES_SHARING_API_USER2);
-               \OC_User::deleteUser(self::TEST_FILES_SHARING_API_USER3);
+               $user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER1);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER2);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3);
+               if ($user !== null) { $user->delete(); }
 
                // delete group
                \OC_Group::deleteGroup(self::TEST_FILES_SHARING_API_GROUP1);
index 387bb20c6d486fe1d602d5ac8a025b45837dcebb..30735fe7bc363ebee25d89eb9cd3e6f69222e592 100644 (file)
@@ -75,7 +75,8 @@ class Storage extends \Test\TestCase {
        protected function tearDown() {
                \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
                $this->logout();
-               \OC_User::deleteUser($this->user);
+               $user = \OC::$server->getUserManager()->get($this->user);
+               if ($user !== null) { $user->delete(); }
                \OC_Hook::clear();
                parent::tearDown();
        }
index e8d586816c3962734cd8c21b4129cf5a24197778..9c19b67a904d63f3ace91519b930ed2751bb157e 100644 (file)
@@ -88,7 +88,8 @@ class Test_Trashbin extends \Test\TestCase {
 
        public static function tearDownAfterClass() {
                // cleanup test user
-               \OC_User::deleteUser(self::TEST_TRASHBIN_USER1);
+               $user = \OC::$server->getUserManager()->get(self::TEST_TRASHBIN_USER1);
+               if ($user !== null) { $user->delete(); }
 
                \OC::$server->getConfig()->setSystemValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
 
index ffc98c2e98ce6e915076049dc896653d101c5441..ee4978ff7840c7392d178f7d62d4fc269c195f4f 100644 (file)
@@ -61,8 +61,10 @@ class Test_Files_Versioning extends \Test\TestCase {
 
        public static function tearDownAfterClass() {
                // cleanup test user
-               \OC_User::deleteUser(self::TEST_VERSIONS_USER);
-               \OC_User::deleteUser(self::TEST_VERSIONS_USER2);
+               $user = \OC::$server->getUserManager()->get(self::TEST_VERSIONS_USER);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get(self::TEST_VERSIONS_USER2);
+               if ($user !== null) { $user->delete(); }
 
                parent::tearDownAfterClass();
        }
index e84da5cf843a2170733ca4de3e9e8b1507a7ae62..f806aa07251fdd78ef6e0cac89a6a7df7e81bd6d 100644 (file)
@@ -152,24 +152,6 @@ class OC_User {
                }
        }
 
-       /**
-        * delete a user
-        *
-        * @param string $uid The username of the user to delete
-        * @return bool
-        *
-        * Deletes a user
-        * @deprecated Use \OC::$server->getUserManager()->get() and then run delete() on the return
-        */
-       public static function deleteUser($uid) {
-               $user = \OC::$server->getUserManager()->get($uid);
-               if ($user) {
-                       return $user->delete();
-               } else {
-                       return false;
-               }
-       }
-
        /**
         * Try to login a user
         *
index 6ae095fa5c2f01e8bf00aae1bfbc960ae93f77d9..d674ac27fa11835243714d7a08062821931667f2 100644 (file)
@@ -373,7 +373,8 @@ class Cache extends \Test\TestCase {
                $tagManager->delete('tag2');
 
                $this->logout();
-               \OC_User::deleteUser($userId);
+               $user = \OC::$server->getUserManager()->get($userId);
+               if ($user !== null) { $user->delete(); }
        }
 
        function testMove() {
index ca59850eb0b3983d4a159414b9c734d53165fd60..09688afd465fa728876674bd662ed3135dfbbae1 100644 (file)
@@ -72,7 +72,10 @@ class UpdaterLegacy extends \Test\TestCase {
                if ($this->cache) {
                        $this->cache->clear();
                }
-               $result = \OC_User::deleteUser(self::$user);
+
+               $result = false;
+               $user = \OC::$server->getUserManager()->get(self::$user);
+               if ($user !== null) { $result = $user->delete(); }
                $this->assertTrue($result);
 
                $this->logout();
index 1de8cba54461a5bbdbe136e77fe3863cf3ad1c65..de8979affd16e4be5c58afb3da5b2fdc8e45e113 100644 (file)
@@ -340,7 +340,8 @@ class Filesystem extends \Test\TestCase {
                        $this->assertEquals('home::' . $userId, $homeMount->getId());
                }
 
-               \OC_User::deleteUser($userId);
+               $user = \OC::$server->getUserManager()->get($userId);
+               if ($user !== null) { $user->delete(); }
        }
 
        /**
@@ -368,7 +369,8 @@ class Filesystem extends \Test\TestCase {
                $this->assertTrue($homeMount->instanceOfStorage('\OC\Files\Storage\Home'));
                $this->assertEquals('local::' . $datadir . '/' . $userId . '/', $homeMount->getId());
 
-               \OC_User::deleteUser($userId);
+               $user = \OC::$server->getUserManager()->get($userId);
+               if ($user !== null) { $user->delete(); }
                // delete storage entry
                $cache->clear();
        }
@@ -398,7 +400,8 @@ class Filesystem extends \Test\TestCase {
                list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
                $this->assertTrue($storage->instanceOfStorage('\OCP\Files\IHomeStorage'));
                $this->assertEquals('cache', $internalPath);
-               \OC_User::deleteUser($userId);
+               $user = \OC::$server->getUserManager()->get($userId);
+               if ($user !== null) { $user->delete(); }
 
                $config->setSystemValue('cache_path', $oldCachePath);
        }
@@ -426,7 +429,8 @@ class Filesystem extends \Test\TestCase {
                list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
                $this->assertTrue($storage->instanceOfStorage('\OC\Files\Storage\Local'));
                $this->assertEquals('', $internalPath);
-               \OC_User::deleteUser($userId);
+               $user = \OC::$server->getUserManager()->get($userId);
+               if ($user !== null) { $user->delete(); }
 
                $config->setSystemValue('cache_path', $oldCachePath);
        }
index 906efb6390f0e97b03d99d4c2b83134f5df05ba0..a63f5844145d08c6faa12a75f55f7aa3b371c345 100644 (file)
@@ -51,7 +51,8 @@ class Swift extends \Test\Files\Storage\Storage {
                // create users
                $users = array('test');
                foreach($users as $userName) {
-                       \OC_User::deleteUser($userName);
+                       $user = \OC::$server->getUserManager()->get($userName);
+                       if ($user !== null) { $user->delete(); }
                        \OC::$server->getUserManager()->createUser($userName, $userName);
                }
 
@@ -76,7 +77,8 @@ class Swift extends \Test\Files\Storage\Storage {
 
                $users = array('test');
                foreach($users as $userName) {
-                       \OC_User::deleteUser($userName);
+                       $user = \OC::$server->getUserManager()->get($userName);
+                       if ($user !== null) { $user->delete(); }
                }
                parent::tearDown();
        }
index bee05438c80cdeed07e7032abf39fac6231cda2c..9a3c6b151fce61b183acfeab9b8a3efdd9f0219f 100644 (file)
@@ -44,7 +44,8 @@ class HomeStorageQuota extends \Test\TestCase {
 
                // clean up
                \OC_User::setUserId('');
-               \OC_User::deleteUser($user1);
+               $user = \OC::$server->getUserManager()->get($user1);
+               if ($user !== null) { $user->delete(); }
                \OC::$server->getConfig()->deleteAllUserValues($user1);
                \OC_Util::tearDownFS();
        }
@@ -71,7 +72,8 @@ class HomeStorageQuota extends \Test\TestCase {
 
                // clean up
                \OC_User::setUserId('');
-               \OC_User::deleteUser($user1);
+               $user = \OC::$server->getUserManager()->get($user1);
+               if ($user !== null) { $user->delete(); }
                \OC::$server->getConfig()->deleteAllUserValues($user1);
                \OC_Util::tearDownFS();
        }
index 1b2d1ec4feae93183aad550a6a5cfae20b37eb46..3109b5095492a2d5947559d5c45df83e5b0925cf 100644 (file)
@@ -45,7 +45,8 @@ class Test_Helper_Storage extends \Test\TestCase {
                \OC\Files\Filesystem::mount($this->storage, array(), '/');
 
                \OC_User::setUserId('');
-               \OC_User::deleteUser($this->user);
+               $user = \OC::$server->getUserManager()->get($this->user);
+               if ($user !== null) { $user->delete(); }
                \OC::$server->getConfig()->deleteAllUserValues($this->user);
 
                parent::tearDown();
index a4e6d8d68ac6f73a5a82a13761b7bd5327f0758b..f2e29cab18e78c15a5cc03344b60c1241ba8ff38 100644 (file)
@@ -39,7 +39,8 @@ class CertificateManagerTest extends \Test\TestCase {
        }
 
        protected function tearDown() {
-               \OC_User::deleteUser($this->username);
+               $user = \OC::$server->getUserManager()->get($this->username);
+               if ($user !== null) { $user->delete(); }
                parent::tearDown();
        }
 
index 273073239c98db9ef14a63538e386f2d2fcc5165..5162a03f367493051c99d58543543ee714461276 100644 (file)
@@ -94,13 +94,20 @@ class Test_Share extends \Test\TestCase {
                $query->execute(array('test'));
                \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', $this->resharing);
 
-               OC_User::deleteUser($this->user1);
-               OC_User::deleteUser($this->user2);
-               OC_User::deleteUser($this->user3);
-               OC_User::deleteUser($this->user4);
-               OC_User::deleteUser($this->user5);
-               OC_User::deleteUser($this->user6);
-               OC_User::deleteUser($this->groupAndUser);
+               $user = \OC::$server->getUserManager()->get($this->user1);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get($this->user2);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get($this->user3);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get($this->user4);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get($this->user5);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get($this->user6);
+               if ($user !== null) { $user->delete(); }
+               $user = \OC::$server->getUserManager()->get($this->groupAndUser);
+               if ($user !== null) { $user->delete(); }
 
                OC_Group::deleteGroup($this->group1);
                OC_Group::deleteGroup($this->group2);
@@ -375,7 +382,8 @@ class Test_Share extends \Test\TestCase {
 
                // Remove user
                OC_User::setUserId($this->user1);
-               OC_User::deleteUser($this->user1);
+               $user = \OC::$server->getUserManager()->get($this->user1);
+               if ($user !== null) { $user->delete(); }
                OC_User::setUserId($this->user2);
                $this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));
        }
index 26596e2fb540406e22d03e052ccc9e9634db27c5..c4c74cbc254f9d7c501990a65d0d0c0346e521f2 100644 (file)
@@ -51,15 +51,5 @@ class User extends TestCase {
                $uid = \OC_User::checkPassword('foo', 'bar');
                $this->assertEquals($uid, 'foo');
        }
-       
-       public function testDeleteUser() {
-               $fail = \OC_User::deleteUser('victim');
-               $this->assertFalse($fail);
-               
-               $success = \OC::$server->getUserManager()->createUser('victim', 'password');
-               
-               $success = \OC_User::deleteUser('victim');
-               $this->assertTrue($success);
-       }
 
 }