[Pkg-owncloud-commits] [owncloud] 06/62: Backported unit tests from 31e94708f86e21174e4bcfaf33f645dbba1efc1e

David Prévot taffit at moszumanska.debian.org
Tue Jun 23 23:39:32 UTC 2015


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

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

commit 960ca7b1a82808b7f3135e852960607ceadda1fe
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Mon Jun 1 12:27:38 2015 +0200

    Backported unit tests from 31e94708f86e21174e4bcfaf33f645dbba1efc1e
    
    Partial backport, only took the unit tests from
    31e94708f86e21174e4bcfaf33f645dbba1efc1e to simulate failure using mocks
    instead of the quota storage wrapper.
---
 tests/lib/files/view.php | 83 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 79 insertions(+), 4 deletions(-)

diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 54d8ff6..c8629ab 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -16,6 +16,26 @@ class TemporaryNoTouch extends \OC\Files\Storage\Temporary {
 	}
 }
 
+class TemporaryNoCross extends \OC\Files\Storage\Temporary {
+	public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
+		return Common::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
+	}
+
+	public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
+		return Common::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
+	}
+}
+
+class TemporaryNoLocal extends \OC\Files\Storage\Temporary {
+	public function instanceOfStorage($className) {
+		if ($className === '\OC\Files\Storage\Local') {
+			return false;
+		} else {
+			return parent::instanceOfStorage($className);
+		}
+	}
+}
+
 class View extends \Test\TestCase {
 	/**
 	 * @var \OC\Files\Storage\Storage[] $storages
@@ -294,9 +314,31 @@ class View extends \Test\TestCase {
 	/**
 	 * @medium
 	 */
-	function testCopyBetweenStorages() {
+	function testCopyBetweenStorageNoCross() {
+		$storage1 = $this->getTestStorage(true, '\Test\Files\TemporaryNoCross');
+		$storage2 = $this->getTestStorage(true, '\Test\Files\TemporaryNoCross');
+		$this->copyBetweenStorages($storage1, $storage2);
+	}
+
+	/**
+	 * @medium
+	 */
+	function testCopyBetweenStorageCross() {
 		$storage1 = $this->getTestStorage();
 		$storage2 = $this->getTestStorage();
+		$this->copyBetweenStorages($storage1, $storage2);
+	}
+
+	/**
+	 * @medium
+	 */
+	function testCopyBetweenStorageCrossNonLocal() {
+		$storage1 = $this->getTestStorage(true, '\Test\Files\TemporaryNoLocal');
+		$storage2 = $this->getTestStorage(true, '\Test\Files\TemporaryNoLocal');
+		$this->copyBetweenStorages($storage1, $storage2);
+	}
+
+	function copyBetweenStorages($storage1, $storage2) {
 		\OC\Files\Filesystem::mount($storage1, array(), '/');
 		\OC\Files\Filesystem::mount($storage2, array(), '/substorage');
 
@@ -318,9 +360,31 @@ class View extends \Test\TestCase {
 	/**
 	 * @medium
 	 */
-	function testMoveBetweenStorages() {
+	function testMoveBetweenStorageNoCross() {
+		$storage1 = $this->getTestStorage(true, '\Test\Files\TemporaryNoCross');
+		$storage2 = $this->getTestStorage(true, '\Test\Files\TemporaryNoCross');
+		$this->moveBetweenStorages($storage1, $storage2);
+	}
+
+	/**
+	 * @medium
+	 */
+	function testMoveBetweenStorageCross() {
 		$storage1 = $this->getTestStorage();
 		$storage2 = $this->getTestStorage();
+		$this->moveBetweenStorages($storage1, $storage2);
+	}
+
+	/**
+	 * @medium
+	 */
+	function testMoveBetweenStorageCrossNonLocal() {
+		$storage1 = $this->getTestStorage(true, '\Test\Files\TemporaryNoLocal');
+		$storage2 = $this->getTestStorage(true, '\Test\Files\TemporaryNoLocal');
+		$this->moveBetweenStorages($storage1, $storage2);
+	}
+
+	function moveBetweenStorages($storage1, $storage2) {
 		\OC\Files\Filesystem::mount($storage1, array(), '/');
 		\OC\Files\Filesystem::mount($storage2, array(), '/substorage');
 
@@ -882,8 +946,19 @@ class View extends \Test\TestCase {
 
 	private function doTestCopyRenameFail($operation) {
 		$storage1 = new Temporary(array());
-		$storage2 = new Temporary(array());
-		$storage2 = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage2, 'quota' => 9));
+		/** @var \PHPUnit_Framework_MockObject_MockObject | \OC\Files\Storage\Temporary $storage2 */
+		$storage2 = $this->getMockBuilder('\Test\Files\TemporaryNoCross')
+			->setConstructorArgs([[]])
+			->setMethods(['fopen'])
+			->getMock();
+
+		$storage2->expects($this->any())
+			->method('fopen')
+			->will($this->returnCallback(function ($path, $mode) use ($storage2) {
+				$source = fopen($storage2->getSourcePath($path), $mode);
+				return \OC\Files\Stream\Quota::wrap($source, 9);
+			}));
+
 		$storage1->mkdir('sub');
 		$storage1->file_put_contents('foo.txt', '0123456789ABCDEFGH');
 		$storage1->mkdir('dirtomove');

-- 
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