66namespace OCA \DAV \Tests \Unit \DAV \Settings ;
77
88use OCA \DAV \Settings \CalDAVSettings ;
9+ use OCP \App \IAppManager ;
910use OCP \AppFramework \Http \TemplateResponse ;
1011use OCP \AppFramework \Services \IInitialState ;
1112use OCP \IConfig ;
@@ -24,6 +25,9 @@ class CalDAVSettingsTest extends TestCase {
2425 /** @var IURLGenerator|MockObject */
2526 private $ urlGenerator ;
2627
28+ /** @var IAppManager|MockObject */
29+ private $ appManager ;
30+
2731 private CalDAVSettings $ settings ;
2832
2933 protected function setUp (): void {
@@ -32,7 +36,8 @@ protected function setUp(): void {
3236 $ this ->config = $ this ->createMock (IConfig::class);
3337 $ this ->initialState = $ this ->createMock (IInitialState::class);
3438 $ this ->urlGenerator = $ this ->createMock (IURLGenerator::class);
35- $ this ->settings = new CalDAVSettings ($ this ->config , $ this ->initialState , $ this ->urlGenerator );
39+ $ this ->appManager = $ this ->createMock (IAppManager::class);
40+ $ this ->settings = new CalDAVSettings ($ this ->config , $ this ->initialState , $ this ->urlGenerator , $ this ->appManager );
3641 }
3742
3843 public function testGetForm (): void {
@@ -65,10 +70,23 @@ public function testGetForm(): void {
6570 }
6671
6772 public function testGetSection (): void {
73+ $ this ->appManager ->expects (self ::once ())
74+ ->method ('isBackendRequired ' )
75+ ->with (IAppManager::BACKEND_CALDAV )
76+ ->willReturn (true );
6877 $ this ->assertEquals ('groupware ' , $ this ->settings ->getSection ());
6978 }
7079
80+ public function testGetSectionWithoutCaldavBackend (): void {
81+ $ this ->appManager ->expects (self ::once ())
82+ ->method ('isBackendRequired ' )
83+ ->with (IAppManager::BACKEND_CALDAV )
84+ ->willReturn (false );
85+ $ this ->assertEquals (null , $ this ->settings ->getSection ());
86+ }
87+
7188 public function testGetPriority (): void {
7289 $ this ->assertEquals (10 , $ this ->settings ->getPriority ());
7390 }
91+
7492}
0 commit comments