diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2024-03-13 01:21:40 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2024-03-13 02:22:11 -0100 |
commit | 519e4345739876d2ae7e064e347d19524905b090 (patch) | |
tree | 0b997f8d18f54efcb97e9278503ae42e119fd9b6 /apps/updatenotification/tests | |
parent | 5723c13dc0c7f4025c4d976c1f792f9bb3513fe2 (diff) | |
download | nextcloud-server-519e4345739876d2ae7e064e347d19524905b090.tar.gz nextcloud-server-519e4345739876d2ae7e064e347d19524905b090.zip |
fix(updatenotification): spread the use of new appconfig
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'apps/updatenotification/tests')
-rw-r--r-- | apps/updatenotification/tests/Settings/AdminTest.php | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php index bdde25aceca..7776fa692cd 100644 --- a/apps/updatenotification/tests/Settings/AdminTest.php +++ b/apps/updatenotification/tests/Settings/AdminTest.php @@ -34,6 +34,7 @@ use OCA\UpdateNotification\Settings\Admin; use OCA\UpdateNotification\UpdateChecker; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Services\IInitialState; +use OCP\IAppConfig; use OCP\IConfig; use OCP\IDateTimeFormatter; use OCP\IGroup; @@ -55,6 +56,8 @@ class AdminTest extends TestCase { private $admin; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; + /** @var IAppConfig|\PHPUnit\Framework\MockObject\MockObject */ + private $appConfig; /** @var UpdateChecker|\PHPUnit\Framework\MockObject\MockObject */ private $updateChecker; /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */ @@ -74,6 +77,7 @@ class AdminTest extends TestCase { parent::setUp(); $this->config = $this->createMock(IConfig::class); + $this->appConfig = $this->createMock(IAppConfig::class); $this->updateChecker = $this->createMock(UpdateChecker::class); $this->groupManager = $this->createMock(IGroupManager::class); $this->dateTimeFormatter = $this->createMock(IDateTimeFormatter::class); @@ -85,6 +89,7 @@ class AdminTest extends TestCase { $this->admin = new Admin( $this->config, + $this->appConfig, $this->updateChecker, $this->groupManager, $this->dateTimeFormatter, @@ -143,14 +148,16 @@ class AdminTest extends TestCase { if ($currentChannel === 'git') { $channels[] = 'git'; } - + $this->appConfig + ->expects($this->once()) + ->method('getValueInt') + ->with('core', 'lastupdatedat', 0) + ->willReturn(12345); $this->config - ->expects($this->exactly(2)) + ->expects($this->once()) ->method('getAppValue') - ->willReturnMap([ - ['core', 'lastupdatedat', '', '12345'], - ['updatenotification', 'notify_groups', '["admin"]', '["admin"]'], - ]); + ->with('updatenotification', 'notify_groups', '["admin"]') + ->willReturn('["admin"]'); $this->config ->method('getSystemValue') ->willReturnMap([ @@ -160,7 +167,7 @@ class AdminTest extends TestCase { $this->dateTimeFormatter ->expects($this->once()) ->method('formatDateTime') - ->with('12345') + ->with(12345) ->willReturn('LastCheckedReturnValue'); $this->updateChecker ->expects($this->once()) @@ -268,13 +275,16 @@ class AdminTest extends TestCase { $channels[] = 'git'; } + $this->appConfig + ->expects($this->once()) + ->method('getValueInt') + ->with('core', 'lastupdatedat', 0) + ->willReturn(12345); $this->config - ->expects($this->exactly(2)) + ->expects($this->once()) ->method('getAppValue') - ->willReturnMap([ - ['core', 'lastupdatedat', '', '12345'], - ['updatenotification', 'notify_groups', '["admin"]', '["admin"]'], - ]); + ->with('updatenotification', 'notify_groups', '["admin"]') + ->willReturn('["admin"]'); $this->config ->method('getSystemValue') ->willReturnMap([ @@ -392,13 +402,16 @@ class AdminTest extends TestCase { $channels[] = 'git'; } + $this->appConfig + ->expects($this->once()) + ->method('getValueInt') + ->with('core', 'lastupdatedat', 0) + ->willReturn(12345); $this->config - ->expects($this->exactly(2)) + ->expects($this->once()) ->method('getAppValue') - ->willReturnMap([ - ['core', 'lastupdatedat', '', '12345'], - ['updatenotification', 'notify_groups', '["admin"]', '["admin"]'], - ]); + ->with('updatenotification', 'notify_groups', '["admin"]') + ->willReturn('["admin"]'); $this->config ->method('getSystemValue') ->willReturnMap([ |