summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/app/infoparser.php3
-rw-r--r--tests/lib/httphelper.php24
-rw-r--r--tests/lib/share/backend.php4
-rw-r--r--tests/lib/share/share.php17
-rw-r--r--tests/lib/updater.php28
5 files changed, 60 insertions, 16 deletions
diff --git a/tests/lib/app/infoparser.php b/tests/lib/app/infoparser.php
index e291b616e8b..762a3584cd2 100644
--- a/tests/lib/app/infoparser.php
+++ b/tests/lib/app/infoparser.php
@@ -21,8 +21,9 @@ class InfoParser extends \PHPUnit_Framework_TestCase {
public function setUp() {
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
+ $certificateManager = $this->getMock('\OCP\ICertificateManager');
$httpHelper = $this->getMockBuilder('\OC\HTTPHelper')
- ->setConstructorArgs(array($config))
+ ->setConstructorArgs(array($config, $certificateManager))
->setMethods(array('getHeaders'))
->getMock();
$urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
diff --git a/tests/lib/httphelper.php b/tests/lib/httphelper.php
index 1cc4232ab4b..48d6543f1f2 100644
--- a/tests/lib/httphelper.php
+++ b/tests/lib/httphelper.php
@@ -12,14 +12,17 @@ class TestHTTPHelper extends \Test\TestCase {
private $config;
/** @var \OC\HTTPHelper */
private $httpHelperMock;
+ /** @var \OC\Security\CertificateManager */
+ private $certificateManager;
protected function setUp() {
parent::setUp();
$this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
+ $this->certificateManager = $this->getMock('\OCP\ICertificateManager');
$this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
- ->setConstructorArgs(array($this->config))
+ ->setConstructorArgs(array($this->config, $this->certificateManager))
->setMethods(array('getHeaders'))
->getMock();
}
@@ -87,4 +90,23 @@ class TestHTTPHelper extends \Test\TestCase {
$this->assertSame($expected, $this->httpHelperMock->isHTTPURL($url));
}
+
+ /**
+ * @dataProvider postParameters
+ */
+ public function testassemblePostParameters($parameterList, $expectedResult) {
+ $helper = \OC::$server->getHTTPHelper();
+ $result = \Test_Helper::invokePrivate($helper, 'assemblePostParameters', array($parameterList));
+ $this->assertSame($expectedResult, $result);
+ }
+
+ public function postParameters() {
+ return array(
+ array(array('k1' => 'v1'), 'k1=v1'),
+ array(array('k1' => 'v1', 'k2' => 'v2'), 'k1=v1&k2=v2'),
+ array(array(), ''),
+ );
+ }
+
+
}
diff --git a/tests/lib/share/backend.php b/tests/lib/share/backend.php
index 07958266947..9c0d7fcb020 100644
--- a/tests/lib/share/backend.php
+++ b/tests/lib/share/backend.php
@@ -84,4 +84,8 @@ class Test_Share_Backend implements OCP\Share_Backend {
return $testItems;
}
+ public function isShareTypeAllowed($shareType) {
+ return true;
+ }
+
}
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 1f95502919d..b8abfa29a81 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -849,6 +849,23 @@ class Test_Share extends \Test\TestCase {
}
/**
+ * @dataProvider urls
+ */
+ function testRemoveProtocolFromUrl($url, $expectedResult) {
+ $share = new \OC\Share\Share();
+ $result = \Test_Helper::invokePrivate($share, 'removeProtocolFromUrl', array($url));
+ $this->assertSame($expectedResult, $result);
+ }
+
+ function urls() {
+ return array(
+ array('http://owncloud.org', 'owncloud.org'),
+ array('https://owncloud.org', 'owncloud.org'),
+ array('owncloud.org', 'owncloud.org'),
+ );
+ }
+
+ /**
* @dataProvider dataProviderTestGroupItems
* @param type $ungrouped
* @param type $grouped
diff --git a/tests/lib/updater.php b/tests/lib/updater.php
index 2dab2750dcd..f847ffc91bf 100644
--- a/tests/lib/updater.php
+++ b/tests/lib/updater.php
@@ -30,30 +30,30 @@ class UpdaterTest extends \Test\TestCase {
$updater = new Updater(\OC::$server->getHTTPHelper(), \OC::$server->getConfig());
$this->assertSame($result, $updater->isUpgradePossible($oldVersion, $newVersion));
}
-
+
public function testBrokenXmlResponse(){
$invalidUpdater = $this->getUpdaterMock('OMG!');
$invalidResult = $invalidUpdater->check();
$this->assertEmpty($invalidResult);
}
-
+
public function testEmptyResponse(){
$emptyUpdater = $this->getUpdaterMock('');
$emptyResult = $emptyUpdater->check();
$this->assertEmpty($emptyResult);
-
+
// Error while fetching new contents e.g. too many redirects
$falseUpdater = $this->getUpdaterMock(false);
$falseResult = $falseUpdater->check();
$this->assertEmpty($falseResult);
}
-
+
public function testValidEmptyXmlResponse(){
$updater = $this->getUpdaterMock(
'<?xml version="1.0"?><owncloud><version></version><versionstring></versionstring><url></url><web></web></owncloud>'
);
$result = array_map('strval', $updater->check());
-
+
$this->assertArrayHasKey('version', $result);
$this->assertArrayHasKey('versionstring', $result);
$this->assertArrayHasKey('url', $result);
@@ -63,7 +63,7 @@ class UpdaterTest extends \Test\TestCase {
$this->assertEmpty($result['url']);
$this->assertEmpty($result['web']);
}
-
+
public function testValidUpdateResponse(){
$newUpdater = $this->getUpdaterMock(
'<?xml version="1.0"?>
@@ -75,7 +75,7 @@ class UpdaterTest extends \Test\TestCase {
</owncloud>'
);
$newResult = array_map('strval', $newUpdater->check());
-
+
$this->assertArrayHasKey('version', $newResult);
$this->assertArrayHasKey('versionstring', $newResult);
$this->assertArrayHasKey('url', $newResult);
@@ -85,22 +85,22 @@ class UpdaterTest extends \Test\TestCase {
$this->assertEquals('http://download.owncloud.org/community/owncloud-7.0.3.zip', $newResult['url']);
$this->assertEquals('http://owncloud.org/', $newResult['web']);
}
-
+
protected function getUpdaterMock($content){
// Invalidate cache
$mockedAppConfig = $this->getMockBuilder('\OC\AppConfig')
->disableOriginalConstructor()
->getMock()
;
-
+
+ $certificateManager = $this->getMock('\OCP\ICertificateManager');
$mockedHTTPHelper = $this->getMockBuilder('\OC\HTTPHelper')
- ->setConstructorArgs(array(\OC::$server->getConfig()))
+ ->setConstructorArgs(array(\OC::$server->getConfig(), $certificateManager))
->getMock()
;
-
- $mockedHTTPHelper->method('getUrlContent')
- ->willReturn($content)
- ;
+
+ $mockedHTTPHelper->expects($this->once())->method('getUrlContent')->will($this->returnValue($content));
+
return new Updater($mockedHTTPHelper, $mockedAppConfig);
}