[Pkg-owncloud-commits] [owncloud] 53/86: Fix more unit tests to pass a mock storage instead of null to FileInfo

David Prévot taffit at moszumanska.debian.org
Tue Dec 22 16:51:59 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v8.1.5
in repository owncloud.

commit 5ecd8cc24d4d73862b0e3a33fc17b7386ab684c1
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Tue Dec 8 16:33:39 2015 +0100

    Fix more unit tests to pass a mock storage instead of null to FileInfo
---
 tests/lib/connector/sabre/file.php | 42 +++++++++++++++++++++++---------------
 tests/lib/files/node/file.php      | 10 ++++++++-
 tests/lib/files/node/folder.php    | 10 ++++++++-
 tests/lib/files/node/node.php      | 10 ++++++++-
 4 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php
index 246f7f6..c9c7f55 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 e3b8019..82d364c 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 eacd2b9..3bdc0a6 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 01ed84c..3b9eaa8 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() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list