99namespace OCA \DAV \Tests \unit \CalDAV ;
1010
1111use DateTimeZone ;
12+ use OCA \DAV \CalDAV \CalDavBackend ;
1213use OCA \DAV \CalDAV \CalendarImpl ;
1314use OCA \DAV \CalDAV \TimezoneService ;
1415use OCA \DAV \Db \Property ;
1516use OCA \DAV \Db \PropertyMapper ;
1617use OCP \Calendar \ICalendar ;
1718use OCP \Calendar \IManager ;
19+ use OCP \Config \IUserConfig ;
1820use OCP \IConfig ;
1921use PHPUnit \Framework \MockObject \MockObject ;
2022use Sabre \VObject \Component \VTimeZone ;
2123use Test \TestCase ;
2224
2325class TimezoneServiceTest extends TestCase {
2426 private IConfig &MockObject $ config ;
27+ private IUserConfig &MockObject $ userConfig ;
2528 private PropertyMapper &MockObject $ propertyMapper ;
2629 private IManager &MockObject $ calendarManager ;
2730 private TimezoneService $ service ;
@@ -30,19 +33,21 @@ protected function setUp(): void {
3033 parent ::setUp ();
3134
3235 $ this ->config = $ this ->createMock (IConfig::class);
36+ $ this ->userConfig = $ this ->createMock (IUserConfig::class);
3337 $ this ->propertyMapper = $ this ->createMock (PropertyMapper::class);
3438 $ this ->calendarManager = $ this ->createMock (IManager::class);
3539
3640 $ this ->service = new TimezoneService (
3741 $ this ->config ,
42+ $ this ->userConfig ,
3843 $ this ->propertyMapper ,
3944 $ this ->calendarManager ,
4045 );
4146 }
4247
4348 public function testGetUserTimezoneFromSettings (): void {
44- $ this ->config ->expects (self ::once ())
45- ->method ('getUserValue ' )
49+ $ this ->userConfig ->expects (self ::once ())
50+ ->method ('getValueString ' )
4651 ->with ('test123 ' , 'core ' , 'timezone ' , '' )
4752 ->willReturn ('Europe/Warsaw ' );
4853
@@ -52,8 +57,8 @@ public function testGetUserTimezoneFromSettings(): void {
5257 }
5358
5459 public function testGetUserTimezoneFromAvailability (): void {
55- $ this ->config ->expects (self ::once ())
56- ->method ('getUserValue ' )
60+ $ this ->userConfig ->expects (self ::once ())
61+ ->method ('getValueString ' )
5762 ->with ('test123 ' , 'core ' , 'timezone ' , '' )
5863 ->willReturn ('' );
5964 $ property = new Property ();
@@ -76,11 +81,11 @@ public function testGetUserTimezoneFromAvailability(): void {
7681 }
7782
7883 public function testGetUserTimezoneFromPersonalCalendar (): void {
79- $ this ->config ->expects (self ::exactly (2 ))
80- ->method ('getUserValue ' )
84+ $ this ->userConfig ->expects (self ::exactly (2 ))
85+ ->method ('getValueString ' )
8186 ->willReturnMap ([
82- ['test123 ' , 'core ' , 'timezone ' , '' , '' ],
83- ['test123 ' , 'dav ' , 'defaultCalendar ' , '' , 'personal-1 ' ],
87+ ['test123 ' , 'core ' , 'timezone ' , '' , false , '' ],
88+ ['test123 ' , 'dav ' , 'defaultCalendar ' , CalDavBackend:: PERSONAL_CALENDAR_URI , false , 'personal-1 ' ],
8489 ]);
8590 $ other = $ this ->createMock (ICalendar::class);
8691 $ other ->method ('getUri ' )->willReturn ('other ' );
@@ -105,11 +110,11 @@ public function testGetUserTimezoneFromPersonalCalendar(): void {
105110 }
106111
107112 public function testGetUserTimezoneFromAny (): void {
108- $ this ->config ->expects (self ::exactly (2 ))
109- ->method ('getUserValue ' )
113+ $ this ->userConfig ->expects (self ::exactly (2 ))
114+ ->method ('getValueString ' )
110115 ->willReturnMap ([
111- ['test123 ' , 'core ' , 'timezone ' , '' , '' ],
112- ['test123 ' , 'dav ' , 'defaultCalendar ' , '' , 'personal-1 ' ],
116+ ['test123 ' , 'core ' , 'timezone ' , '' , false , '' ],
117+ ['test123 ' , 'dav ' , 'defaultCalendar ' , CalDavBackend:: PERSONAL_CALENDAR_URI , false , 'personal-1 ' ],
113118 ]);
114119 $ other = $ this ->createMock (ICalendar::class);
115120 $ other ->method ('getUri ' )->willReturn ('other ' );
0 commit comments