[Pkg-owncloud-commits] [owncloud] 135/215: Add tests for the remote sharing url

David Prévot taffit at moszumanska.debian.org
Tue May 5 01:01:38 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 d146c13abd74f5919c08f5a936f0c9d35791be8f
Author: Joas Schilling <nickvergessen at owncloud.com>
Date:   Mon Apr 27 22:07:35 2015 +0200

    Add tests for the remote sharing url
---
 tests/lib/share/share.php | 55 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 53 insertions(+), 2 deletions(-)

diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 124ad45..5d8f61f 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -105,6 +105,12 @@ class Test_Share extends \Test\TestCase {
 		parent::tearDown();
 	}
 
+	protected function setHttpHelper($httpHelper) {
+		\OC::$server->registerService('HTTPHelper', function ($c) use ($httpHelper) {
+			return $httpHelper;
+		});
+	}
+
 	public function testShareInvalidShareType() {
 		$message = 'Share type foobar is not valid for test.txt';
 		try {
@@ -1024,10 +1030,55 @@ class Test_Share extends \Test\TestCase {
 		);
 	}
 
+	public function dataRemoteShareUrlCalls() {
+		return [
+			['admin at localhost', 'localhost'],
+			['admin at https://localhost', 'localhost'],
+			['admin at http://localhost', 'localhost'],
+			['admin at localhost/subFolder', 'localhost/subFolder'],
+		];
+	}
+
+	/**
+	 * @dataProvider dataRemoteShareUrlCalls
+	 *
+	 * @param string $shareWith
+	 * @param string $urlHost
+	 */
+	public function testRemoteShareUrlCalls($shareWith, $urlHost) {
+		$oldHttpHelper = \OC::$server->query('HTTPHelper');
+		$httpHelperMock = $this->getMockBuilder('OC\HttpHelper')
+			->disableOriginalConstructor()
+			->getMock();
+		$this->setHttpHelper($httpHelperMock);
+
+		$httpHelperMock->expects($this->at(0))
+			->method('post')
+			->with($this->stringStartsWith('https://' . $urlHost . '/ocs/v1.php/cloud/shares'), $this->anything())
+			->willReturn(['success' => false, 'result' => 'Exception']);
+		$httpHelperMock->expects($this->at(1))
+			->method('post')
+			->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v1.php/cloud/shares'), $this->anything())
+			->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]);
+
+		$httpHelperMock->expects($this->at(2))
+			->method('post')
+			->with($this->stringStartsWith('https://' . $urlHost . '/ocs/v1.php/cloud/shares'), $this->anything())
+			->willReturn(['success' => false, 'result' => 'Exception']);
+		$httpHelperMock->expects($this->at(3))
+			->method('post')
+			->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v1.php/cloud/shares'), $this->anything())
+			->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]);
+
+		\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith, \OCP\Constants::PERMISSION_READ);
+		\OCP\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith);
+		$this->setHttpHelper($oldHttpHelper);
+	}
+
 	/**
 	 * @dataProvider dataProviderTestGroupItems
-	 * @param type $ungrouped
-	 * @param type $grouped
+	 * @param array $ungrouped
+	 * @param array $grouped
 	 */
 	function testGroupItems($ungrouped, $grouped) {
 

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