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

David Prévot taffit at moszumanska.debian.org
Thu Dec 17 19:40:36 UTC 2015


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

taffit pushed a commit to branch stable8
in repository owncloud.

commit 6004eb5edfdd0d41490ff00a91706870420368ed
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 | 43 ++++++++++++++++++++++++--------------
 tests/lib/files/node/file.php      | 10 ++++++++-
 tests/lib/files/node/folder.php    | 10 ++++++++-
 tests/lib/files/node/node.php      | 10 ++++++++-
 4 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php
index 2dc6278..38821aa 100644
--- a/tests/lib/connector/sabre/file.php
+++ b/tests/lib/connector/sabre/file.php
@@ -40,6 +40,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);
@@ -134,7 +145,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);
 
@@ -194,7 +205,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);
@@ -202,7 +213,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);
@@ -244,7 +255,7 @@ class File extends \Test\TestCase {
 
 		$info = new \OC\Files\FileInfo(
 			$viewRoot . '/' . ltrim($path, '/'),
-			null,
+			$this->getMockStorage(),
 			null,
 			['permissions' => \OCP\Constants::PERMISSION_ALL],
 			null
@@ -433,7 +444,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);
 
@@ -466,7 +477,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);
 
@@ -501,13 +512,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);
@@ -534,7 +545,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);
@@ -570,7 +581,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);
@@ -597,7 +608,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);
 
@@ -633,7 +644,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);
 
@@ -651,7 +662,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);
 
@@ -674,7 +685,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);
 
@@ -709,7 +720,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
@@ -821,7 +832,7 @@ class File extends \Test\TestCase {
 			->method('fopen')
 			->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);
 
diff --git a/tests/lib/files/node/file.php b/tests/lib/files/node/file.php
index c431a2e..1b2fa3d 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 \Test\Util\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 8c98256..526c51f 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 \Test\Util\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 afcf4cb..a1693b0 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 \Test\Util\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