diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-06-26 17:25:37 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-06-29 09:11:04 +0200 |
commit | 25d9c3e52921b107383e5d05f3649178bd7cd1cf (patch) | |
tree | 837fb580784174aa14a1d412056b1e9bf4f61772 /apps/updatenotification/tests/UpdateCheckerTest.php | |
parent | 4ed8ee1c1e8ada0e5d26f6e014896accc89d4d6a (diff) | |
download | nextcloud-server-25d9c3e52921b107383e5d05f3649178bd7cd1cf.tar.gz nextcloud-server-25d9c3e52921b107383e5d05f3649178bd7cd1cf.zip |
adjust backend and gui to update and changelog server
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/updatenotification/tests/UpdateCheckerTest.php')
-rw-r--r-- | apps/updatenotification/tests/UpdateCheckerTest.php | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/apps/updatenotification/tests/UpdateCheckerTest.php b/apps/updatenotification/tests/UpdateCheckerTest.php index 0a82f950b9a..16861eea54e 100644 --- a/apps/updatenotification/tests/UpdateCheckerTest.php +++ b/apps/updatenotification/tests/UpdateCheckerTest.php @@ -25,11 +25,14 @@ declare(strict_types=1); namespace OCA\UpdateNotification\Tests; +use OC\Updater\ChangesCheck; use OC\Updater\VersionCheck; use OCA\UpdateNotification\UpdateChecker; use Test\TestCase; class UpdateCheckerTest extends TestCase { + /** @var ChangesCheck|\PHPUnit_Framework_MockObject_MockObject */ + protected $changesChecker; /** @var VersionCheck|\PHPUnit_Framework_MockObject_MockObject */ private $updater; /** @var UpdateChecker */ @@ -39,7 +42,8 @@ class UpdateCheckerTest extends TestCase { parent::setUp(); $this->updater = $this->createMock(VersionCheck::class); - $this->updateChecker = new UpdateChecker($this->updater); + $this->changesChecker = $this->createMock(ChangesCheck::class); + $this->updateChecker = new UpdateChecker($this->updater, $this->changesChecker); } public function testGetUpdateStateWithUpdateAndInvalidLink() { @@ -51,8 +55,7 @@ class UpdateCheckerTest extends TestCase { 'versionstring' => 'Nextcloud 123', 'web'=> 'javascript:alert(1)', 'url'=> 'javascript:alert(2)', - 'changelog' => 'javascript:alert(3)', - 'whatsNew' => 'javascript:alert(4)', + 'changes' => 'javascript:alert(3)', 'autoupdater'=> '0', 'eol'=> '1', ]); @@ -67,20 +70,40 @@ class UpdateCheckerTest extends TestCase { } public function testGetUpdateStateWithUpdateAndValidLink() { + $changes = [ + 'changelog' => 'https://nextcloud.com/changelog/#123-0-0', + 'whatsNew' => [ + 'en' => [ + 'regular' => [ + 'Yardarm heave to brig spyglass smartly pillage', + 'Bounty gangway bilge skysail rope\'s end', + 'Maroon cutlass spirits nipperkin Plate Fleet', + ], + 'admin' => [ + 'Scourge of the seven seas coffer doubloon', + 'Brig me splice the main brace', + ] + ] + ] + ]; + $this->updater ->expects($this->once()) ->method('check') ->willReturn([ - 'version' => 123, + 'version' => '123', 'versionstring' => 'Nextcloud 123', 'web'=> 'https://docs.nextcloud.com/myUrl', 'url'=> 'https://downloads.nextcloud.org/server', - 'changelog' => 'https://nextcloud.com/changelog/#123.0.0', - 'whatsNew' => ['Brews coffee', 'Makes appointments', 'Orchestrates Terminators'], + 'changes' => 'https://updates.nextcloud.com/changelog_server/?version=123.0.0', 'autoupdater'=> '1', 'eol'=> '0', ]); + $this->changesChecker->expects($this->once()) + ->method('check') + ->willReturn($changes); + $expected = [ 'updateAvailable' => true, 'updateVersion' => 'Nextcloud 123', @@ -88,8 +111,7 @@ class UpdateCheckerTest extends TestCase { 'versionIsEol' => false, 'updateLink' => 'https://docs.nextcloud.com/myUrl', 'downloadLink' => 'https://downloads.nextcloud.org/server', - 'changelog' => 'https://nextcloud.com/changelog/#123.0.0', - 'whatsNew' => ['Brews coffee', 'Makes appointments', 'Orchestrates Terminators'], + 'changes' => $changes, ]; $this->assertSame($expected, $this->updateChecker->getUpdateState()); } |