aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/Stream/QuotaTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Files/Stream/QuotaTest.php')
-rw-r--r--tests/lib/Files/Stream/QuotaTest.php44
1 files changed, 23 insertions, 21 deletions
diff --git a/tests/lib/Files/Stream/QuotaTest.php b/tests/lib/Files/Stream/QuotaTest.php
index 69cd322a2b3..4248d14f5a1 100644
--- a/tests/lib/Files/Stream/QuotaTest.php
+++ b/tests/lib/Files/Stream/QuotaTest.php
@@ -1,13 +1,15 @@
<?php
+
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Stream;
+use OC\Files\Stream\Quota;
+
class QuotaTest extends \Test\TestCase {
/**
* @param string $mode
@@ -16,24 +18,24 @@ class QuotaTest extends \Test\TestCase {
*/
protected function getStream($mode, $limit) {
$source = fopen('php://temp', $mode);
- return \OC\Files\Stream\Quota::wrap($source, $limit);
+ return Quota::wrap($source, $limit);
}
- public function testWriteEnoughSpace() {
+ public function testWriteEnoughSpace(): void {
$stream = $this->getStream('w+', 100);
$this->assertEquals(6, fwrite($stream, 'foobar'));
rewind($stream);
$this->assertEquals('foobar', fread($stream, 100));
}
- public function testWriteNotEnoughSpace() {
+ public function testWriteNotEnoughSpace(): void {
$stream = $this->getStream('w+', 3);
$this->assertEquals(3, fwrite($stream, 'foobar'));
rewind($stream);
$this->assertEquals('foo', fread($stream, 100));
}
- public function testWriteNotEnoughSpaceSecondTime() {
+ public function testWriteNotEnoughSpaceSecondTime(): void {
$stream = $this->getStream('w+', 9);
$this->assertEquals(6, fwrite($stream, 'foobar'));
$this->assertEquals(3, fwrite($stream, 'qwerty'));
@@ -41,7 +43,7 @@ class QuotaTest extends \Test\TestCase {
$this->assertEquals('foobarqwe', fread($stream, 100));
}
- public function testWriteEnoughSpaceRewind() {
+ public function testWriteEnoughSpaceRewind(): void {
$stream = $this->getStream('w+', 6);
$this->assertEquals(6, fwrite($stream, 'foobar'));
rewind($stream);
@@ -50,7 +52,7 @@ class QuotaTest extends \Test\TestCase {
$this->assertEquals('qwebar', fread($stream, 100));
}
- public function testWriteNotEnoughSpaceRead() {
+ public function testWriteNotEnoughSpaceRead(): void {
$stream = $this->getStream('w+', 6);
$this->assertEquals(6, fwrite($stream, 'foobar'));
rewind($stream);
@@ -58,26 +60,26 @@ class QuotaTest extends \Test\TestCase {
$this->assertEquals(0, fwrite($stream, 'qwe'));
}
- public function testWriteNotEnoughSpaceExistingStream() {
+ public function testWriteNotEnoughSpaceExistingStream(): void {
$source = fopen('php://temp', 'w+');
fwrite($source, 'foobar');
- $stream = \OC\Files\Stream\Quota::wrap($source, 3);
+ $stream = Quota::wrap($source, 3);
$this->assertEquals(3, fwrite($stream, 'foobar'));
rewind($stream);
$this->assertEquals('foobarfoo', fread($stream, 100));
}
- public function testWriteNotEnoughSpaceExistingStreamRewind() {
+ public function testWriteNotEnoughSpaceExistingStreamRewind(): void {
$source = fopen('php://temp', 'w+');
fwrite($source, 'foobar');
- $stream = \OC\Files\Stream\Quota::wrap($source, 3);
+ $stream = Quota::wrap($source, 3);
rewind($stream);
$this->assertEquals(6, fwrite($stream, 'qwerty'));
rewind($stream);
$this->assertEquals('qwerty', fread($stream, 100));
}
- public function testFseekReturnsSuccess() {
+ public function testFseekReturnsSuccess(): void {
$stream = $this->getStream('w+', 100);
fwrite($stream, '0123456789');
$this->assertEquals(0, fseek($stream, 3, SEEK_SET));
@@ -85,7 +87,7 @@ class QuotaTest extends \Test\TestCase {
$this->assertEquals(0, fseek($stream, -4, SEEK_END));
}
- public function testWriteAfterSeekEndWithEnoughSpace() {
+ public function testWriteAfterSeekEndWithEnoughSpace(): void {
$stream = $this->getStream('w+', 100);
fwrite($stream, '0123456789');
fseek($stream, -3, SEEK_END);
@@ -94,7 +96,7 @@ class QuotaTest extends \Test\TestCase {
$this->assertEquals('0123456abcdefghijk', fread($stream, 100));
}
- public function testWriteAfterSeekEndWithNotEnoughSpace() {
+ public function testWriteAfterSeekEndWithNotEnoughSpace(): void {
$stream = $this->getStream('w+', 13);
fwrite($stream, '0123456789');
// seek forward first to potentially week out
@@ -107,7 +109,7 @@ class QuotaTest extends \Test\TestCase {
$this->assertEquals('0123456abcdef', fread($stream, 100));
}
- public function testWriteAfterSeekSetWithEnoughSpace() {
+ public function testWriteAfterSeekSetWithEnoughSpace(): void {
$stream = $this->getStream('w+', 100);
fwrite($stream, '0123456789');
fseek($stream, 7, SEEK_SET);
@@ -116,7 +118,7 @@ class QuotaTest extends \Test\TestCase {
$this->assertEquals('0123456abcdefghijk', fread($stream, 100));
}
- public function testWriteAfterSeekSetWithNotEnoughSpace() {
+ public function testWriteAfterSeekSetWithNotEnoughSpace(): void {
$stream = $this->getStream('w+', 13);
fwrite($stream, '0123456789');
fseek($stream, 7, SEEK_SET);
@@ -125,7 +127,7 @@ class QuotaTest extends \Test\TestCase {
$this->assertEquals('0123456abcdef', fread($stream, 100));
}
- public function testWriteAfterSeekCurWithEnoughSpace() {
+ public function testWriteAfterSeekCurWithEnoughSpace(): void {
$stream = $this->getStream('w+', 100);
fwrite($stream, '0123456789');
rewind($stream);
@@ -137,7 +139,7 @@ class QuotaTest extends \Test\TestCase {
$this->assertEquals('0123456abcdefghijk', fread($stream, 100));
}
- public function testWriteAfterSeekCurWithNotEnoughSpace() {
+ public function testWriteAfterSeekCurWithNotEnoughSpace(): void {
$stream = $this->getStream('w+', 13);
fwrite($stream, '0123456789');
rewind($stream);