summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVictor Dubiniuk <victor.dubiniuk@gmail.com>2014-12-10 01:13:38 +0300
committerVictor Dubiniuk <victor.dubiniuk@gmail.com>2014-12-10 01:13:38 +0300
commitc9fd3c9d2960c6457440427513f04a4f338a23d5 (patch)
tree81166aeedd483ced13863347820233e3491ea8f0 /tests
parent81d571241991926f8820c43020a0250eb305a0b0 (diff)
downloadnextcloud-server-c9fd3c9d2960c6457440427513f04a4f338a23d5.tar.gz
nextcloud-server-c9fd3c9d2960c6457440427513f04a4f338a23d5.zip
Inject config
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/updater.php47
1 files changed, 26 insertions, 21 deletions
diff --git a/tests/lib/updater.php b/tests/lib/updater.php
index 832f60fac06..dc1e9e5446f 100644
--- a/tests/lib/updater.php
+++ b/tests/lib/updater.php
@@ -27,13 +27,28 @@ class UpdaterTest extends \Test\TestCase {
* @dataProvider versionCompatibilityTestData
*/
public function testIsUpgradePossible($oldVersion, $newVersion, $result) {
- $updater = new Updater(\OC::$server->getHTTPHelper());
+ $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 testCheck(){
- // Valid XML. Empty values
+ public function testValidEmptyXmlResponse(){
$updater = $this->getUpdaterMock(
'<?xml version="1.0"?><owncloud><version></version><versionstring></versionstring><url></url><web></web></owncloud>'
);
@@ -47,18 +62,9 @@ class UpdaterTest extends \Test\TestCase {
$this->assertEmpty($result['versionstring']);
$this->assertEmpty($result['url']);
$this->assertEmpty($result['web']);
-
- // Empty feed
- $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);
-
- // Valid XML. New version available
+ }
+
+ public function testValidUpdateResponse(){
$newUpdater = $this->getUpdaterMock(
'<?xml version="1.0"?>
<owncloud>
@@ -78,15 +84,14 @@ class UpdaterTest extends \Test\TestCase {
$this->assertEquals('ownCloud 7.0.3', $newResult['versionstring']);
$this->assertEquals('http://download.owncloud.org/community/owncloud-7.0.3.zip', $newResult['url']);
$this->assertEquals('http://owncloud.org/', $newResult['web']);
-
- // Invalid XML
- $invalidUpdater = $this->getUpdaterMock('OMG!');
- $invalidResult = $invalidUpdater->check();
- $this->assertEmpty($invalidResult);
}
protected function getUpdaterMock($content){
// Invalidate cache
+ $mockedAppConfig = $this->getMockBuilder('\OC\AppConfig')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ;
\OC_Appconfig::setValue('core', 'lastupdatedat', 0);
$mockedHTTPHelper = $this->getMockBuilder('\OC\HTTPHelper')
@@ -97,7 +102,7 @@ class UpdaterTest extends \Test\TestCase {
$mockedHTTPHelper->method('getUrlContent')
->willReturn($content)
;
- return new Updater($mockedHTTPHelper);
+ return new Updater($mockedHTTPHelper, $mockedAppConfig);
}
}