diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-09-15 18:17:54 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-09-15 18:18:30 +0200 |
commit | 954f4940cf53b4ed6acda7331c0c1b5d34b888f2 (patch) | |
tree | 8faf48b4053cddf2009c5753e0a426cb9d5c2e17 /apps/updatenotification | |
parent | ca747b91d4aa907b191119f080d213bfb5e60fd2 (diff) | |
download | nextcloud-server-954f4940cf53b4ed6acda7331c0c1b5d34b888f2.tar.gz nextcloud-server-954f4940cf53b4ed6acda7331c0c1b5d34b888f2.zip |
Fix test update notification
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/updatenotification')
-rw-r--r-- | apps/updatenotification/tests/Settings/AdminTest.php | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php index 489679dfabd..784e56e79ed 100644 --- a/apps/updatenotification/tests/Settings/AdminTest.php +++ b/apps/updatenotification/tests/Settings/AdminTest.php @@ -42,6 +42,7 @@ use OCP\L10N\ILanguageIterator; use OCP\Support\Subscription\IRegistry; use OCP\UserInterface; use OCP\User\Backend\ICountUsersBackend; +use OCP\AppFramework\Services\IInitialState; use OCP\Util; use OC\User\Backend; use Psr\Log\LoggerInterface; @@ -66,6 +67,8 @@ class AdminTest extends TestCase { private $userManager; /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; + /** IInitialState|\PHPUnit\Framework\MockObject\MockObject */ + private $initialState; protected function setUp(): void { parent::setUp(); @@ -78,6 +81,7 @@ class AdminTest extends TestCase { $this->subscriptionRegistry = $this->createMock(IRegistry::class); $this->userManager = $this->createMock(IUserManager::class); $this->logger = $this->createMock(LoggerInterface::class); + $this->initialState = $this->createMock(IInitialState::class); $this->admin = new Admin( $this->config, @@ -87,7 +91,8 @@ class AdminTest extends TestCase { $this->l10nFactory, $this->subscriptionRegistry, $this->userManager, - $this->logger + $this->logger, + $this->initialState ); } @@ -187,8 +192,9 @@ class AdminTest extends TestCase { ->method('delegateHasValidSubscription') ->willReturn(true); - $params = [ - 'json' => json_encode([ + $this->initialState->expects($this->once()) + ->method('provideInitialState') + ->with('data', [ 'isNewVersionAvailable' => true, 'isUpdateChecked' => true, 'lastChecked' => 'LastCheckedReturnValue', @@ -205,13 +211,12 @@ class AdminTest extends TestCase { 'isDefaultUpdateServerURL' => true, 'updateServerURL' => 'https://updates.nextcloud.com/updater_server/', 'notifyGroups' => [ - ['value' => 'admin', 'label' => 'Administrators'], + ['id' => 'admin', 'displayname' => 'Administrators'], ], 'hasValidSubscription' => true, - ]), - ]; + ]); - $expected = new TemplateResponse('updatenotification', 'admin', $params, ''); + $expected = new TemplateResponse('updatenotification', 'admin', [], ''); $this->assertEquals($expected, $this->admin->getForm()); } @@ -311,8 +316,9 @@ class AdminTest extends TestCase { ->method('delegateHasValidSubscription') ->willReturn(true); - $params = [ - 'json' => json_encode([ + $this->initialState->expects($this->once()) + ->method('provideInitialState') + ->with('data', [ 'isNewVersionAvailable' => true, 'isUpdateChecked' => true, 'lastChecked' => 'LastCheckedReturnValue', @@ -329,13 +335,12 @@ class AdminTest extends TestCase { 'isDefaultUpdateServerURL' => false, 'updateServerURL' => 'https://updates.nextcloud.com/updater_server_changed/', 'notifyGroups' => [ - ['value' => 'admin', 'label' => 'Administrators'], + ['id' => 'admin', 'displayname' => 'Administrators'], ], 'hasValidSubscription' => true, - ]), - ]; + ]); - $expected = new TemplateResponse('updatenotification', 'admin', $params, ''); + $expected = new TemplateResponse('updatenotification', 'admin', [], ''); $this->assertEquals($expected, $this->admin->getForm()); } @@ -435,8 +440,9 @@ class AdminTest extends TestCase { ->method('delegateHasValidSubscription') ->willReturn(true); - $params = [ - 'json' => json_encode([ + $this->initialState->expects($this->once()) + ->method('provideInitialState') + ->with('data', [ 'isNewVersionAvailable' => true, 'isUpdateChecked' => true, 'lastChecked' => 'LastCheckedReturnValue', @@ -453,13 +459,12 @@ class AdminTest extends TestCase { 'isDefaultUpdateServerURL' => true, 'updateServerURL' => 'https://updates.nextcloud.com/customers/ABC-DEF/', 'notifyGroups' => [ - ['value' => 'admin', 'label' => 'Administrators'], + ['id' => 'admin', 'displayname' => 'Administrators'], ], 'hasValidSubscription' => true, - ]), - ]; + ]); - $expected = new TemplateResponse('updatenotification', 'admin', $params, ''); + $expected = new TemplateResponse('updatenotification', 'admin', [], ''); $this->assertEquals($expected, $this->admin->getForm()); } |