diff options
author | Victor Dubiniuk <victor.dubiniuk@gmail.com> | 2014-11-26 19:18:22 +0300 |
---|---|---|
committer | Victor Dubiniuk <victor.dubiniuk@gmail.com> | 2014-12-06 20:17:59 +0300 |
commit | 2a3f5ccae3f43c4a34c6aff536ded9e802d7523d (patch) | |
tree | 0b30540c610954a6c2dbb4eb9e5dff43092a9fd3 /tests | |
parent | 303fce44f487e50a09910acdb28bc6c99b4b04b8 (diff) | |
download | nextcloud-server-2a3f5ccae3f43c4a34c6aff536ded9e802d7523d.tar.gz nextcloud-server-2a3f5ccae3f43c4a34c6aff536ded9e802d7523d.zip |
Test OC\Updater::check
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/updater.php | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/tests/lib/updater.php b/tests/lib/updater.php index 155dccf78a7..5a05bc09bb7 100644 --- a/tests/lib/updater.php +++ b/tests/lib/updater.php @@ -26,9 +26,65 @@ class UpdaterTest extends \Test\TestCase { /** * @dataProvider versionCompatibilityTestData */ - function testIsUpgradePossible($oldVersion, $newVersion, $result) { - $updater = new Updater(); + public function testIsUpgradePossible($oldVersion, $newVersion, $result) { + $updater = new Updater(\OC::$server->getHTTPHelper()); $this->assertSame($result, $updater->isUpgradePossible($oldVersion, $newVersion)); } + + + public function testCheck(){ + $httpHelper = $this->getMockBuilder('\OC\HTTPHelper') + ->getMock(); + + $httpHelper->method('getUrlContent') + ->willReturn( + '<?xml version="1.0"?><owncloud><version></version><versionstring></versionstring><url></url><web></web></owncloud>' + ) + ; + + $updater = new Updater($httpHelper); + // Invalidate cache + \OC_Appconfig::setValue('core', 'lastupdatedat', 0); + $result = $updater->check(); + $this->assertContains('version', $result); + $this->assertContains('versionstring', $result); + $this->assertContains('url', $result); + $this->assertContains('web', $result); + $this->assertEmpty($result['version']); + $this->assertEmpty($result['versionstring']); + $this->assertEmpty($result['url']); + $this->assertEmpty($result['web']); + + // Invalidate cache + \OC_Appconfig::setValue('core', 'lastupdatedat', 0); + $httpHelper->method('getUrlContent') + ->willReturn('') + ; + + $emptyResult = $updater->check(); + $this->assertEmpty($emptyResult); + + // Invalidate cache + \OC_Appconfig::setValue('core', 'lastupdatedat', 0); + $httpHelper->method('getUrlContent') + ->willReturn('<?xml version="1.0"?> +<owncloud> + <version>7.0.3.4</version> + <versionstring>ownCloud 7.0.3</versionstring> + <url>http://download.owncloud.org/community/owncloud-7.0.3.zip</url> + <web>http://owncloud.org/</web> +</owncloud>') + ; + + $newResult = $updater->check(); + $this->assertContains('version', $newResult); + $this->assertContains('versionstring', $newResult); + $this->assertContains('url', $newResult); + $this->assertContains('web', $newResult); + $this->assertEqual('7.0.3.4', $newResult['version']); + $this->assertEqual('ownCloud 7.0.3', $newResult['versionstring']); + $this->assertEqual('http://download.owncloud.org/community/owncloud-7.0.3.zip', $newResult['url']); + $this->assertEqual('http://owncloud.org/', $newResult['web']); + } }
\ No newline at end of file |