Skip to content

Commit 539e4c1

Browse files
committed
add show_tasks to php test
Signed-off-by: Boris Fritscher <boris@fritscher.ch>
1 parent d171faa commit 539e4c1

File tree

6 files changed

+61
-27
lines changed

6 files changed

+61
-27
lines changed

lib/Controller/PublicViewController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private function publicIndex(string $token,
113113
$defaultSkipPopover = $this->config->getAppValue($this->appName, 'skipPopover', 'yes');
114114
$defaultTimezone = $this->config->getAppValue($this->appName, 'timezone', 'automatic');
115115
$defaultSlotDuration = $this->config->getAppValue($this->appName, 'slotDuration', '00:30:00');
116-
$defaultShowTasks = $this->config->getAppValue($this->appName, 'showTasks', 'yes');
116+
$defaultShowTasks = $this->config->getAppValue($this->appName, 'showTasks', 'yes');
117117

118118
$appVersion = $this->config->getAppValue($this->appName, 'installed_version');
119119

lib/Controller/SettingsController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ public function setConfig(string $key,
7474
return $this->setView($value);
7575
case 'skipPopover':
7676
return $this->setSkipPopover($value);
77-
case 'showTasks':
78-
return $this->showTasks($value);
7977
case 'showWeekends':
8078
return $this->showWeekends($value);
8179
case 'showWeekNr':
@@ -88,6 +86,8 @@ public function setConfig(string $key,
8886
return $this->setEventLimit($value);
8987
case 'slotDuration':
9088
return $this->setSlotDuration($value);
89+
case 'showTasks':
90+
return $this->setShowTasks($value);
9191
default:
9292
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
9393
}
@@ -150,7 +150,7 @@ private function setSkipPopover(string $value):JSONResponse {
150150
* @param $value User-selected option whether or not to show tasks
151151
* @return JSONResponse
152152
*/
153-
private function showTasks(string $value):JSONResponse {
153+
private function setShowTasks(string $value):JSONResponse {
154154
if (!\in_array($value, ['yes', 'no'])) {
155155
return new JSONResponse([], Http::STATUS_UNPROCESSABLE_ENTITY);
156156
}

lib/Controller/ViewController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function index():TemplateResponse {
9393
$defaultSkipPopover = $this->config->getAppValue($this->appName, 'skipPopover', 'no');
9494
$defaultTimezone = $this->config->getAppValue($this->appName, 'timezone', 'automatic');
9595
$defaultSlotDuration = $this->config->getAppValue($this->appName, 'slotDuration', '00:30:00');
96-
$defaultShowTasks = $this->config->getAppValue($this->appName, 'showTasks', 'yes');
96+
$defaultShowTasks = $this->config->getAppValue($this->appName, 'showTasks', 'yes');
9797

9898
$appVersion = $this->config->getAppValue($this->appName, 'installed_version');
9999
$eventLimit = $this->config->getUserValue($this->userId, $this->appName, 'eventLimit', $defaultEventLimit) === 'yes';
@@ -102,11 +102,12 @@ public function index():TemplateResponse {
102102
$showWeekends = $this->config->getUserValue($this->userId, $this->appName, 'showWeekends', $defaultShowWeekends) === 'yes';
103103
$showWeekNumbers = $this->config->getUserValue($this->userId, $this->appName, 'showWeekNr', $defaultWeekNumbers) === 'yes';
104104
$skipPopover = $this->config->getUserValue($this->userId, $this->appName, 'skipPopover', $defaultSkipPopover) === 'yes';
105-
$talkEnabled = $this->appManager->isEnabledForUser('spreed');
106105
$timezone = $this->config->getUserValue($this->userId, $this->appName, 'timezone', $defaultTimezone);
107106
$slotDuration = $this->config->getUserValue($this->userId, $this->appName, 'slotDuration', $defaultSlotDuration);
108107
$showTasks = $this->config->getUserValue($this->userId, $this->appName, 'showTasks', $defaultShowTasks) === 'yes';
109108

109+
$talkEnabled = $this->appManager->isEnabledForUser('spreed');
110+
110111
$this->initialStateService->provideInitialState($this->appName, 'app_version', $appVersion);
111112
$this->initialStateService->provideInitialState($this->appName, 'event_limit', $eventLimit);
112113
$this->initialStateService->provideInitialState($this->appName, 'first_run', $firstRun);

src/views/Calendar.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export default {
167167
showWeekends: state => state.settings.showWeekends,
168168
showWeekNumbers: state => state.settings.showWeekNumbers,
169169
slotDuration: state => state.settings.slotDuration,
170+
showTasks: state => state.settings.showTasks,
170171
timezone: state => state.settings.timezone,
171172
modificationCount: state => state.calendarObjects.modificationCount,
172173
}),
@@ -300,7 +301,7 @@ export default {
300301
slotDuration: loadState('calendar', 'slot_duration'),
301302
talkEnabled: loadState('calendar', 'talk_enabled'),
302303
timezone: loadState('calendar', 'timezone'),
303-
showTasks: loadState('calendar', 'show_tasks')
304+
showTasks: loadState('calendar', 'show_tasks'),
304305
})
305306
this.$store.dispatch('initializeCalendarJsConfig')
306307

tests/php/unit/Controller/PublicViewControllerTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ public function testPublicIndexWithBranding():void {
8989
->method('getAppValue')
9090
->with('calendar', 'slotDuration', '00:30:00')
9191
->willReturn('defaultSlotDuration');
92-
9392
$this->config->expects($this->at(7))
93+
->method('getAppValue')
94+
->with('calendar', 'showTasks')
95+
->willReturn('yes');
96+
$this->config->expects($this->at(8))
9497
->method('getAppValue')
9598
->with('calendar', 'installed_version')
9699
->willReturn('1.0.0');
@@ -147,6 +150,9 @@ public function testPublicIndexWithBranding():void {
147150
$this->initialStateService->expects($this->at(9))
148151
->method('provideInitialState')
149152
->with('calendar', 'slot_duration', 'defaultSlotDuration');
153+
$this->initialStateService->expects($this->at(10))
154+
->method('provideInitialState')
155+
->with('calendar', 'show_tasks', true);
150156

151157
$response = $this->controller->publicIndexWithBranding('');
152158

@@ -188,8 +194,11 @@ public function testPublicIndexForEmbedding():void {
188194
->method('getAppValue')
189195
->with('calendar', 'slotDuration', '00:30:00')
190196
->willReturn('defaultSlotDuration');
191-
192197
$this->config->expects($this->at(7))
198+
->method('getAppValue')
199+
->with('calendar', 'showTasks', 'yes')
200+
->willReturn('defaultShowTasks');
201+
$this->config->expects($this->at(8))
193202
->method('getAppValue')
194203
->with('calendar', 'installed_version')
195204
->willReturn('1.0.0');
@@ -246,6 +255,9 @@ public function testPublicIndexForEmbedding():void {
246255
$this->initialStateService->expects($this->at(9))
247256
->method('provideInitialState')
248257
->with('calendar', 'slot_duration', 'defaultSlotDuration');
258+
$this->initialStateService->expects($this->at(10))
259+
->method('provideInitialState')
260+
->with('calendar', 'show_tasks', false);
249261

250262
$response = $this->controller->publicIndexForEmbedding('');
251263

tests/php/unit/Controller/ViewControllerTest.php

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,43 +93,50 @@ public function testIndex():void {
9393
->method('getAppValue')
9494
->with('calendar', 'slotDuration', '00:30:00')
9595
->willReturn('defaultSlotDuration');
96-
9796
$this->config->expects($this->at(7))
97+
->method('getAppValue')
98+
->with('calendar', 'showTasks', 'yes')
99+
->willReturn('defaultShowTasks');
100+
$this->config->expects($this->at(8))
98101
->method('getAppValue')
99102
->with('calendar', 'installed_version')
100103
->willReturn('1.0.0');
101-
$this->config->expects($this->at(8))
104+
$this->config->expects($this->at(9))
102105
->method('getUserValue')
103106
->with('user123', 'calendar', 'eventLimit', 'defaultEventLimit')
104107
->willReturn('yes');
105-
$this->config->expects($this->at(9))
108+
$this->config->expects($this->at(10))
106109
->method('getUserValue')
107110
->with('user123', 'calendar', 'firstRun', 'yes')
108111
->willReturn('yes');
109-
$this->config->expects($this->at(10))
112+
$this->config->expects($this->at(11))
110113
->method('getUserValue')
111114
->with('user123', 'calendar', 'currentView', 'defaultCurrentView')
112115
->willReturn('timeGridWeek');
113-
$this->config->expects($this->at(11))
116+
$this->config->expects($this->at(12))
114117
->method('getUserValue')
115118
->with('user123', 'calendar', 'showWeekends', 'defaultShowWeekends')
116119
->willReturn('yes');
117-
$this->config->expects($this->at(12))
120+
$this->config->expects($this->at(13))
118121
->method('getUserValue')
119122
->with('user123', 'calendar', 'showWeekNr', 'defaultShowWeekNr')
120123
->willReturn('yes');
121-
$this->config->expects($this->at(13))
124+
$this->config->expects($this->at(14))
122125
->method('getUserValue')
123126
->with('user123', 'calendar', 'skipPopover', 'defaultSkipPopover')
124127
->willReturn('yes');
125-
$this->config->expects($this->at(14))
128+
$this->config->expects($this->at(15))
126129
->method('getUserValue')
127130
->with('user123', 'calendar', 'timezone', 'defaultTimezone')
128131
->willReturn('Europe/Berlin');
129-
$this->config->expects($this->at(15))
132+
$this->config->expects($this->at(16))
130133
->method('getUserValue')
131134
->with('user123', 'calendar', 'slotDuration', 'defaultSlotDuration')
132135
->willReturn('00:15:00');
136+
$this->config->expects($this->at(17))
137+
->method('getUserValue')
138+
->with('user123', 'calendar', 'showTasks', 'defaultShowTasks')
139+
->willReturn('00:15:00');
133140
$this->appManager->expects($this->at(0))
134141
->method('isEnabledForUser')
135142
->with('spreed')
@@ -165,6 +172,9 @@ public function testIndex():void {
165172
$this->initialStateService->expects($this->at(9))
166173
->method('provideInitialState')
167174
->with('calendar', 'slot_duration', '00:15:00');
175+
$this->initialStateService->expects($this->at(10))
176+
->method('provideInitialState')
177+
->with('calendar', 'show_tasks', false);
168178

169179
$response = $this->controller->index();
170180

@@ -209,43 +219,50 @@ public function testIndexViewFix(string $savedView, string $expectedView):void {
209219
->method('getAppValue')
210220
->with('calendar', 'slotDuration', '00:30:00')
211221
->willReturn('defaultSlotDuration');
212-
213222
$this->config->expects($this->at(7))
223+
->method('getAppValue')
224+
->with('calendar', 'showTasks', 'yes')
225+
->willReturn('defaultShowTasks');
226+
$this->config->expects($this->at(8))
214227
->method('getAppValue')
215228
->with('calendar', 'installed_version')
216229
->willReturn('1.0.0');
217-
$this->config->expects($this->at(8))
230+
$this->config->expects($this->at(9))
218231
->method('getUserValue')
219232
->with('user123', 'calendar', 'eventLimit', 'defaultEventLimit')
220233
->willReturn('yes');
221-
$this->config->expects($this->at(9))
234+
$this->config->expects($this->at(10))
222235
->method('getUserValue')
223236
->with('user123', 'calendar', 'firstRun', 'yes')
224237
->willReturn('yes');
225-
$this->config->expects($this->at(10))
238+
$this->config->expects($this->at(11))
226239
->method('getUserValue')
227240
->with('user123', 'calendar', 'currentView', 'defaultCurrentView')
228241
->willReturn($savedView);
229-
$this->config->expects($this->at(11))
242+
$this->config->expects($this->at(12))
230243
->method('getUserValue')
231244
->with('user123', 'calendar', 'showWeekends', 'defaultShowWeekends')
232245
->willReturn('yes');
233-
$this->config->expects($this->at(12))
246+
$this->config->expects($this->at(13))
234247
->method('getUserValue')
235248
->with('user123', 'calendar', 'showWeekNr', 'defaultShowWeekNr')
236249
->willReturn('yes');
237-
$this->config->expects($this->at(13))
250+
$this->config->expects($this->at(14))
238251
->method('getUserValue')
239252
->with('user123', 'calendar', 'skipPopover', 'defaultSkipPopover')
240253
->willReturn('yes');
241-
$this->config->expects($this->at(14))
254+
$this->config->expects($this->at(15))
242255
->method('getUserValue')
243256
->with('user123', 'calendar', 'timezone', 'defaultTimezone')
244257
->willReturn('Europe/Berlin');
245-
$this->config->expects($this->at(15))
258+
$this->config->expects($this->at(16))
246259
->method('getUserValue')
247260
->with('user123', 'calendar', 'slotDuration', 'defaultSlotDuration')
248261
->willReturn('00:15:00');
262+
$this->config->expects($this->at(17))
263+
->method('getUserValue')
264+
->with('user123', 'calendar', 'showTasks', 'defaultShowTasks')
265+
->willReturn('00:15:00');
249266
$this->appManager->expects($this->at(0))
250267
->method('isEnabledForUser')
251268
->with('spreed')
@@ -281,6 +298,9 @@ public function testIndexViewFix(string $savedView, string $expectedView):void {
281298
$this->initialStateService->expects($this->at(9))
282299
->method('provideInitialState')
283300
->with('calendar', 'slot_duration', '00:15:00');
301+
$this->initialStateService->expects($this->at(10))
302+
->method('provideInitialState')
303+
->with('calendar', 'show_tasks', false);
284304

285305
$response = $this->controller->index();
286306

0 commit comments

Comments
 (0)