replace old views in case migration didn't run correctly
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
parent
5701d101db
commit
d5bcb558a7
|
@ -86,7 +86,7 @@ class ViewController extends Controller {
|
|||
return new TemplateResponse($this->appName, 'main', [
|
||||
'app_version' => $this->config->getAppValue($this->appName, 'installed_version'),
|
||||
'first_run' => $this->config->getUserValue($this->userId, $this->appName, 'firstRun', 'yes') === 'yes',
|
||||
'initial_view' => $this->config->getUserValue($this->userId, $this->appName, 'currentView', $defaultInitialView),
|
||||
'initial_view' => $this->getView($this->config->getUserValue($this->userId, $this->appName, 'currentView', $defaultInitialView)),
|
||||
'show_weekends' => $this->config->getUserValue($this->userId, $this->appName, 'showWeekends', $defaultShowWeekends) === 'yes',
|
||||
'show_week_numbers' => $this->config->getUserValue($this->userId, $this->appName, 'showWeekNr', $defaultWeekNumbers) === 'yes',
|
||||
'skip_popover' => $this->config->getUserValue($this->userId, $this->appName, 'skipPopover', $defaultSkipPopover) === 'yes',
|
||||
|
@ -94,4 +94,26 @@ class ViewController extends Controller {
|
|||
'timezone' => $this->config->getUserValue($this->userId, $this->appName, 'timezone', $defaultTimezone),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure we don't use the old views anymore
|
||||
*
|
||||
* @param string $view
|
||||
* @return string
|
||||
*/
|
||||
private function getView(string $view): string {
|
||||
switch ($view) {
|
||||
case 'agendaDay':
|
||||
return 'timeGridDay';
|
||||
|
||||
case 'agendaWeek':
|
||||
return 'timeGridWeek';
|
||||
|
||||
case 'month':
|
||||
return 'dayGridMonth';
|
||||
|
||||
default:
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,4 +130,96 @@ class ViewControllerTest extends TestCase {
|
|||
$this->assertEquals('user', $response->getRenderAs());
|
||||
$this->assertEquals('main', $response->getTemplateName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider viewFixDataProvider
|
||||
*
|
||||
* @param string $savedView
|
||||
* @param string $expectedView
|
||||
*/
|
||||
public function testIndexViewFix(string $savedView, string $expectedView):void {
|
||||
$this->config->expects($this->at(0))
|
||||
->method('getAppValue')
|
||||
->with('calendar', 'currentView', 'dayGridMonth')
|
||||
->willReturn('defaultCurrentView');
|
||||
$this->config->expects($this->at(1))
|
||||
->method('getAppValue')
|
||||
->with('calendar', 'showWeekends', 'yes')
|
||||
->willReturn('defaultShowWeekends');
|
||||
$this->config->expects($this->at(2))
|
||||
->method('getAppValue')
|
||||
->with('calendar', 'showWeekNr', 'no')
|
||||
->willReturn('defaultShowWeekNr');
|
||||
$this->config->expects($this->at(3))
|
||||
->method('getAppValue')
|
||||
->with('calendar', 'skipPopover', 'no')
|
||||
->willReturn('defaultSkipPopover');
|
||||
$this->config->expects($this->at(4))
|
||||
->method('getAppValue')
|
||||
->with('calendar', 'timezone', 'automatic')
|
||||
->willReturn('defaultTimezone');
|
||||
|
||||
$this->config->expects($this->at(5))
|
||||
->method('getAppValue')
|
||||
->with('calendar', 'installed_version')
|
||||
->willReturn('1.0.0');
|
||||
$this->config->expects($this->at(6))
|
||||
->method('getUserValue')
|
||||
->with('user123', 'calendar', 'firstRun', 'yes')
|
||||
->willReturn('yes');
|
||||
$this->config->expects($this->at(7))
|
||||
->method('getUserValue')
|
||||
->with('user123', 'calendar', 'currentView', 'defaultCurrentView')
|
||||
->willReturn($savedView);
|
||||
$this->config->expects($this->at(8))
|
||||
->method('getUserValue')
|
||||
->with('user123', 'calendar', 'showWeekends', 'defaultShowWeekends')
|
||||
->willReturn('yes');
|
||||
$this->config->expects($this->at(9))
|
||||
->method('getUserValue')
|
||||
->with('user123', 'calendar', 'showWeekNr', 'defaultShowWeekNr')
|
||||
->willReturn('yes');
|
||||
$this->config->expects($this->at(10))
|
||||
->method('getUserValue')
|
||||
->with('user123', 'calendar', 'skipPopover', 'defaultSkipPopover')
|
||||
->willReturn('yes');
|
||||
$this->config->expects($this->at(11))
|
||||
->method('getUserValue')
|
||||
->with('user123', 'calendar', 'timezone', 'defaultTimezone')
|
||||
->willReturn('Europe/Berlin');
|
||||
$this->appManager->expects($this->at(0))
|
||||
->method('isEnabledForUser')
|
||||
->with('spreed')
|
||||
->willReturn(true);
|
||||
|
||||
$response = $this->controller->index();
|
||||
|
||||
$this->assertInstanceOf(TemplateResponse::class, $response);
|
||||
$this->assertEquals([
|
||||
'app_version' => '1.0.0',
|
||||
'first_run' => true,
|
||||
'initial_view' => $expectedView,
|
||||
'show_weekends' => true,
|
||||
'show_week_numbers' => true,
|
||||
'skip_popover' => true,
|
||||
'talk_enabled' => true,
|
||||
'timezone' => 'Europe/Berlin',
|
||||
], $response->getParams());
|
||||
$this->assertEquals('user', $response->getRenderAs());
|
||||
$this->assertEquals('main', $response->getTemplateName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function viewFixDataProvider(): array {
|
||||
return [
|
||||
['agendaDay', 'timeGridDay'],
|
||||
['timeGridDay', 'timeGridDay'],
|
||||
['agendaWeek', 'timeGridWeek'],
|
||||
['timeGridWeek', 'timeGridWeek'],
|
||||
['month', 'dayGridMonth'],
|
||||
['dayGridMonth', 'dayGridMonth'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue