]> source.dussan.org Git - nextcloud-server.git/commitdiff
more robust test setup
authorRobin Appelman <robin@icewind.nl>
Tue, 20 Sep 2016 13:27:40 +0000 (15:27 +0200)
committerRobin Appelman <robin@icewind.nl>
Wed, 12 Oct 2016 14:12:34 +0000 (16:12 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_sharing/tests/ApiTest.php
apps/files_sharing/tests/External/ManagerTest.php
apps/files_sharing/tests/TestCase.php

index 19f3ad3b36b55d414c829f966ba122ef896ebe55..0a8b4b119cd1f922da38e9766b95158f632bd73a 100644 (file)
@@ -1194,14 +1194,11 @@ class ApiTest extends TestCase {
         * Tests mounting a folder that is an external storage mount point.
         */
        public function testShareStorageMountPoint() {
-               self::$tempStorage = new \OC\Files\Storage\Temporary(array());
-               self::$tempStorage->file_put_contents('test.txt', 'abcdef');
-               self::$tempStorage->getScanner()->scan('');
-
-               // needed because the sharing code sometimes switches the user internally and mounts the user's
-               // storages. In our case the temp storage isn't mounted automatically, so doing it in the post hook
-               // (similar to how ext storage works)
-               \OCP\Util::connectHook('OC_Filesystem', 'post_initMountPoints', '\OCA\Files_Sharing\Tests\ApiTest', 'initTestMountPointsHook');
+               $tempStorage = new \OC\Files\Storage\Temporary(array());
+               $tempStorage->file_put_contents('test.txt', 'abcdef');
+               $tempStorage->getScanner()->scan('');
+
+               $this->registerMount(self::TEST_FILES_SHARING_API_USER1, $tempStorage, self::TEST_FILES_SHARING_API_USER1 . '/files' . self::TEST_FOLDER_NAME);
 
                // logging in will auto-mount the temp storage for user1 as well
                self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
index 096bbe85776d28543979a4041951d6c7aa44ab17..48476888bddae4e78bf76e2d61f769e6b4d04093 100644 (file)
@@ -58,7 +58,7 @@ class ManagerTest extends TestCase {
         * @var \OCP\IUser
         */
        private $user;
-       private $mountProvider;
+       private $testMountProvider;
 
        protected function setUp() {
                parent::setUp();
@@ -82,13 +82,13 @@ class ManagerTest extends TestCase {
                        $discoveryManager,
                        $this->uid
                );
-               $this->mountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function() {
+               $this->testMountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function() {
                        return $this->manager;
                });
        }
 
        private function setupMounts() {
-               $mounts = $this->mountProvider->getMountsForUser($this->user, new StorageFactory());
+               $mounts = $this->testMountProvider->getMountsForUser($this->user, new StorageFactory());
                foreach ($mounts as $mount) {
                        $this->mountManager->addMount($mount);
                }
index 0ad58151dbba050b4908ebefe0e488c1666d5022..1777eb5bad22069c0f2af548bbcaf54989904f2b 100644 (file)
 
 namespace OCA\Files_Sharing\Tests;
 
+use OC\Files\Cache\Scanner;
 use OC\Files\Filesystem;
 use OCA\Files_Sharing\AppInfo\Application;
+use Test\Traits\MountProviderTrait;
 
 /**
  * Class TestCase
@@ -42,6 +44,7 @@ use OCA\Files_Sharing\AppInfo\Application;
  * Base class for sharing tests.
  */
 abstract class TestCase extends \Test\TestCase {
+       use MountProviderTrait;
 
        const TEST_FILES_SHARING_API_USER1 = "test-share-user1";
        const TEST_FILES_SHARING_API_USER2 = "test-share-user2";