summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-12-08 16:33:39 +0100
committerVincent Petry <pvince81@owncloud.com>2015-12-09 15:59:27 +0100
commit5ecd8cc24d4d73862b0e3a33fc17b7386ab684c1 (patch)
tree4bbf8b6d4f20bc1d8f11530cd23f131bb76e8973
parentaf705643353d6991eff7ba6ad32056b99b9a7f3e (diff)
downloadnextcloud-server-5ecd8cc24d4d73862b0e3a33fc17b7386ab684c1.tar.gz
nextcloud-server-5ecd8cc24d4d73862b0e3a33fc17b7386ab684c1.zip
Fix more unit tests to pass a mock storage instead of null to FileInfo
-rw-r--r--tests/lib/connector/sabre/file.php42
-rw-r--r--tests/lib/files/node/file.php10
-rw-r--r--tests/lib/files/node/folder.php10
-rw-r--r--tests/lib/files/node/node.php10
4 files changed, 53 insertions, 19 deletions
diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php
index 246f7f6d0a2..c9c7f55b58a 100644
--- a/tests/lib/connector/sabre/file.php
+++ b/tests/lib/connector/sabre/file.php
@@ -39,6 +39,17 @@ class File extends \Test\TestCase {
parent::tearDown();
}
+ private function getMockStorage() {
+ $storage = $this->getMock('\OCP\Files\Storage');
+ $storage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue('home::someuser'));
+ return $storage;
+ }
+
+ /**
+ * @param string $string
+ */
private function getStream($string) {
$stream = fopen('php://temp', 'r+');
fwrite($stream, $string);
@@ -133,7 +144,7 @@ class File extends \Test\TestCase {
->method('getRelativePath')
->will($this->returnArgument(0));
- $info = new \OC\Files\FileInfo('/test.txt', null, null, array(
+ $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
@@ -193,7 +204,7 @@ class File extends \Test\TestCase {
$_SERVER['HTTP_OC_CHUNKED'] = true;
- $info = new \OC\Files\FileInfo('/test.txt-chunking-12345-2-0', null, null, [
+ $info = new \OC\Files\FileInfo('/test.txt-chunking-12345-2-0', $this->getMockStorage(), null, [
'permissions' => \OCP\Constants::PERMISSION_ALL
], null);
$file = new \OC\Connector\Sabre\File($view, $info);
@@ -201,7 +212,7 @@ class File extends \Test\TestCase {
// put first chunk
$this->assertNull($file->put('test data one'));
- $info = new \OC\Files\FileInfo('/test.txt-chunking-12345-2-1', null, null, [
+ $info = new \OC\Files\FileInfo('/test.txt-chunking-12345-2-1', $this->getMockStorage(), null, [
'permissions' => \OCP\Constants::PERMISSION_ALL
], null);
$file = new \OC\Connector\Sabre\File($view, $info);
@@ -241,7 +252,7 @@ class File extends \Test\TestCase {
$info = new \OC\Files\FileInfo(
$viewRoot . '/' . ltrim($path, '/'),
- null,
+ $this->getMockStorage(),
null,
['permissions' => \OCP\Constants::PERMISSION_ALL],
null
@@ -422,7 +433,7 @@ class File extends \Test\TestCase {
$_SERVER['CONTENT_LENGTH'] = 123456;
$_SERVER['REQUEST_METHOD'] = 'PUT';
- $info = new \OC\Files\FileInfo('/test.txt', null, null, array(
+ $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
@@ -449,7 +460,7 @@ class File extends \Test\TestCase {
// simulate situation where the target file is locked
$view->lockFile('/test.txt', ILockingProvider::LOCK_EXCLUSIVE);
- $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt', null, null, array(
+ $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt', $this->getMockStorage(), null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
@@ -478,13 +489,13 @@ class File extends \Test\TestCase {
$_SERVER['HTTP_OC_CHUNKED'] = true;
- $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt-chunking-12345-2-0', null, null, [
+ $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt-chunking-12345-2-0', $this->getMockStorage(), null, [
'permissions' => \OCP\Constants::PERMISSION_ALL
], null);
$file = new \OC\Connector\Sabre\File($view, $info);
$this->assertNull($file->put('test data one'));
- $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt-chunking-12345-2-1', null, null, [
+ $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt-chunking-12345-2-1', $this->getMockStorage(), null, [
'permissions' => \OCP\Constants::PERMISSION_ALL
], null);
$file = new \OC\Connector\Sabre\File($view, $info);
@@ -511,7 +522,7 @@ class File extends \Test\TestCase {
->method('getRelativePath')
->will($this->returnArgument(0));
- $info = new \OC\Files\FileInfo('/*', null, null, array(
+ $info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
$file = new \OC\Connector\Sabre\File($view, $info);
@@ -541,7 +552,7 @@ class File extends \Test\TestCase {
->method('getRelativePath')
->will($this->returnArgument(0));
- $info = new \OC\Files\FileInfo('/*', null, null, array(
+ $info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
$file = new \OC\Connector\Sabre\File($view, $info);
@@ -568,7 +579,7 @@ class File extends \Test\TestCase {
$_SERVER['CONTENT_LENGTH'] = 12345;
$_SERVER['REQUEST_METHOD'] = 'PUT';
- $info = new \OC\Files\FileInfo('/test.txt', null, null, array(
+ $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
@@ -598,7 +609,7 @@ class File extends \Test\TestCase {
->method('unlink')
->will($this->returnValue(true));
- $info = new \OC\Files\FileInfo('/test.txt', null, null, array(
+ $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
@@ -616,7 +627,7 @@ class File extends \Test\TestCase {
$view = $this->getMock('\OC\Files\View',
array());
- $info = new \OC\Files\FileInfo('/test.txt', null, null, array(
+ $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array(
'permissions' => 0
), null);
@@ -639,7 +650,7 @@ class File extends \Test\TestCase {
->method('unlink')
->will($this->returnValue(false));
- $info = new \OC\Files\FileInfo('/test.txt', null, null, array(
+ $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array(
'permissions' => \OCP\Constants::PERMISSION_ALL
), null);
@@ -674,7 +685,7 @@ class File extends \Test\TestCase {
$path = 'test-locking.txt';
$info = new \OC\Files\FileInfo(
'/' . $this->user . '/files/' . $path,
- null,
+ $this->getMockStorage(),
null,
['permissions' => \OCP\Constants::PERMISSION_ALL],
null
@@ -768,5 +779,4 @@ class File extends \Test\TestCase {
closedir($dh);
return $files;
}
-
}
diff --git a/tests/lib/files/node/file.php b/tests/lib/files/node/file.php
index e3b8019b4ca..82d364c8ee7 100644
--- a/tests/lib/files/node/file.php
+++ b/tests/lib/files/node/file.php
@@ -21,8 +21,16 @@ class File extends \Test\TestCase {
$this->user = new \OC\User\User('', new \OC_User_Dummy);
}
+ protected function getMockStorage() {
+ $storage = $this->getMock('\OCP\Files\Storage');
+ $storage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue('home::someuser'));
+ return $storage;
+ }
+
protected function getFileInfo($data) {
- return new FileInfo('', null, '', $data, null);
+ return new FileInfo('', $this->getMockStorage(), '', $data, null);
}
public function testDelete() {
diff --git a/tests/lib/files/node/folder.php b/tests/lib/files/node/folder.php
index eacd2b9994b..3bdc0a64d15 100644
--- a/tests/lib/files/node/folder.php
+++ b/tests/lib/files/node/folder.php
@@ -24,8 +24,16 @@ class Folder extends \Test\TestCase {
$this->user = new \OC\User\User('', new \OC_User_Dummy);
}
+ protected function getMockStorage() {
+ $storage = $this->getMock('\OCP\Files\Storage');
+ $storage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue('home::someuser'));
+ return $storage;
+ }
+
protected function getFileInfo($data) {
- return new FileInfo('', null, '', $data, null);
+ return new FileInfo('', $this->getMockStorage(), '', $data, null);
}
public function testDelete() {
diff --git a/tests/lib/files/node/node.php b/tests/lib/files/node/node.php
index 01ed84c4a06..3b9eaa85929 100644
--- a/tests/lib/files/node/node.php
+++ b/tests/lib/files/node/node.php
@@ -18,8 +18,16 @@ class Node extends \Test\TestCase {
$this->user = new \OC\User\User('', new \OC_User_Dummy);
}
+ protected function getMockStorage() {
+ $storage = $this->getMock('\OCP\Files\Storage');
+ $storage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue('home::someuser'));
+ return $storage;
+ }
+
protected function getFileInfo($data) {
- return new FileInfo('', null, '', $data, null);
+ return new FileInfo('', $this->getMockStorage(), '', $data, null);
}
public function testStat() {