diff options
Diffstat (limited to 'tests/lib/Files/Storage/Wrapper/QuotaTest.php')
-rw-r--r-- | tests/lib/Files/Storage/Wrapper/QuotaTest.php | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php index f07e6021e4e..2878fe6ca92 100644 --- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php +++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -10,8 +11,10 @@ namespace Test\Files\Storage\Wrapper; //ensure the constants are loaded use OC\Files\Cache\CacheEntry; use OC\Files\Storage\Local; - -\OC::$loader->load('\OC\Files\Filesystem'); +use OC\Files\Storage\Wrapper\Quota; +use OCP\Files; +use OCP\ITempManager; +use OCP\Server; /** * Class QuotaTest @@ -29,13 +32,13 @@ class QuotaTest extends \Test\Files\Storage\Storage { protected function setUp(): void { parent::setUp(); - $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); - $storage = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); - $this->instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => 10000000]); + $this->tmpDir = Server::get(ITempManager::class)->getTemporaryFolder(); + $storage = new Local(['datadir' => $this->tmpDir]); + $this->instance = new Quota(['storage' => $storage, 'quota' => 10000000]); } protected function tearDown(): void { - \OC_Helper::rmdirr($this->tmpDir); + Files::rmdirr($this->tmpDir); parent::tearDown(); } @@ -43,10 +46,10 @@ class QuotaTest extends \Test\Files\Storage\Storage { * @param integer $limit */ protected function getLimitedStorage($limit) { - $storage = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); + $storage = new Local(['datadir' => $this->tmpDir]); $storage->mkdir('files'); $storage->getScanner()->scan(''); - return new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => $limit]); + return new Quota(['storage' => $storage, 'quota' => $limit]); } public function testFilePutContentsNotEnoughSpace(): void { @@ -76,7 +79,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { public function testFreeSpaceWithUnknownDiskSpace(): void { $storage = $this->getMockBuilder(Local::class) - ->setMethods(['free_space']) + ->onlyMethods(['free_space']) ->setConstructorArgs([['datadir' => $this->tmpDir]]) ->getMock(); $storage->expects($this->any()) @@ -84,7 +87,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { ->willReturn(-2); $storage->getScanner()->scan(''); - $instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => 9]); + $instance = new Quota(['storage' => $storage, 'quota' => 9]); $instance->getCache()->put( '', ['size' => 3] ); @@ -132,14 +135,14 @@ class QuotaTest extends \Test\Files\Storage\Storage { public function testReturnFalseWhenFopenFailed(): void { $failStorage = $this->getMockBuilder(Local::class) - ->setMethods(['fopen']) + ->onlyMethods(['fopen']) ->setConstructorArgs([['datadir' => $this->tmpDir]]) ->getMock(); $failStorage->expects($this->any()) ->method('fopen') ->willReturn(false); - $instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $failStorage, 'quota' => 1000]); + $instance = new Quota(['storage' => $failStorage, 'quota' => 1000]); $this->assertFalse($instance->fopen('failedfopen', 'r')); } @@ -197,7 +200,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { ->with('files') ->willReturn(new CacheEntry(['size' => 50])); - $instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => 1024, 'root' => 'files']); + $instance = new Quota(['storage' => $storage, 'quota' => 1024, 'root' => 'files']); $this->assertEquals(1024 - 50, $instance->free_space('')); } |