aboutsummaryrefslogtreecommitdiffstats
path: root/apps/updatenotification/tests
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-09-24 17:23:48 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-09-24 18:53:49 +0200
commit71f1e0cb9c62574f39f6c458f286041184aae9b5 (patch)
tree4e4f5b9ed5f92068940cfcc3d0d7aa03b0ddeb04 /apps/updatenotification/tests
parent280f6df66c199b9e72c23ffa921bbdad7c68d3c0 (diff)
downloadnextcloud-server-71f1e0cb9c62574f39f6c458f286041184aae9b5.tar.gz
nextcloud-server-71f1e0cb9c62574f39f6c458f286041184aae9b5.zip
refactor(updatenotification): Migrate legacy code
1. Remove hook usage and just provide an initial state 2. Replace jQuery code with modern non-deprecated frontend code Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/updatenotification/tests')
-rw-r--r--apps/updatenotification/tests/UpdateCheckerTest.php44
1 files changed, 37 insertions, 7 deletions
diff --git a/apps/updatenotification/tests/UpdateCheckerTest.php b/apps/updatenotification/tests/UpdateCheckerTest.php
index 0497a992669..af6f2c06d09 100644
--- a/apps/updatenotification/tests/UpdateCheckerTest.php
+++ b/apps/updatenotification/tests/UpdateCheckerTest.php
@@ -11,22 +11,28 @@ namespace OCA\UpdateNotification\Tests;
use OC\Updater\ChangesCheck;
use OC\Updater\VersionCheck;
use OCA\UpdateNotification\UpdateChecker;
+use OCP\AppFramework\Services\IInitialState;
+use PHPUnit\Framework\MockObject\MockObject;
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 */
- private $updateChecker;
+
+ private ChangesCheck&MockObject $changesChecker;
+ private VersionCheck&MockObject $updater;
+ private IInitialState&MockObject $initialState;
+ private UpdateChecker $updateChecker;
protected function setUp(): void {
parent::setUp();
$this->updater = $this->createMock(VersionCheck::class);
$this->changesChecker = $this->createMock(ChangesCheck::class);
- $this->updateChecker = new UpdateChecker($this->updater, $this->changesChecker);
+ $this->initialState = $this->createMock(IInitialState::class);
+ $this->updateChecker = new UpdateChecker(
+ $this->updater,
+ $this->changesChecker,
+ $this->initialState,
+ );
}
public function testGetUpdateStateWithUpdateAndInvalidLink(): void {
@@ -110,4 +116,28 @@ class UpdateCheckerTest extends TestCase {
$expected = [];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}
+
+ public function testSetInitialState(): void {
+ $this->updater
+ ->expects($this->once())
+ ->method('check')
+ ->willReturn([
+ 'version' => '1.2.3',
+ 'versionstring' => 'Nextcloud 1.2.3',
+ 'web' => 'https://docs.nextcloud.com/myUrl',
+ 'url' => 'https://downloads.nextcloud.org/server',
+ 'changes' => 'https://updates.nextcloud.com/changelog_server/?version=123.0.0',
+ 'autoupdater' => '1',
+ 'eol' => '0',
+ ]);
+
+ $this->initialState->expects(self::once())
+ ->method('provideInitialState')
+ ->with('updateState', [
+ 'updateVersion' => 'Nextcloud 1.2.3',
+ 'updateLink' => 'https://docs.nextcloud.com/myUrl',
+ ]);
+
+ $this->updateChecker->setInitialState();
+ }
}