Skip to content

Commit 52b7f63

Browse files
committed
test: cover invalid identify methods config fallback
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 58d3f1c commit 52b7f63

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/php/Unit/Service/IdentifyMethod/IdentifyServiceTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace OCA\Libresign\Tests\Unit\Service\IdentifyMethod;
1010

11+
use OCA\Libresign\AppInfo\Application;
1112
use OCA\Libresign\Db\File;
1213
use OCA\Libresign\Db\FileMapper;
1314
use OCA\Libresign\Db\IdentifyMethod;
@@ -153,4 +154,24 @@ public function testPropagateIdentifiedDateSkipsCurrentRequestAndUpdatesSiblings
153154

154155
$this->service->save($identifyMethod);
155156
}
157+
158+
public function testGetSavedSettingsFallsBackToDefaultWhenStoredValueIsInvalid(): void {
159+
$this->appConfig
160+
->expects($this->once())
161+
->method('getValueArray')
162+
->with(Application::APP_ID, 'identify_methods', [])
163+
->willThrowException(new \TypeError('Invalid app config value type'));
164+
165+
$this->logger
166+
->expects($this->once())
167+
->method('warning')
168+
->with(
169+
'Invalid identify_methods app config; falling back to defaults.',
170+
$this->callback(static function (array $context): bool {
171+
return isset($context['exception']) && $context['exception'] instanceof \TypeError;
172+
})
173+
);
174+
175+
$this->assertSame([], $this->service->getSavedSettings());
176+
}
156177
}

0 commit comments

Comments
 (0)