diff --git a/appinfo/info.xml b/appinfo/info.xml index b6afdb3d6..daee54ccd 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -38,11 +38,6 @@ OCA\Calendar\BackgroundJob\CleanUpOutdatedBookingsJob - - - OCA\Calendar\RepairSteps\CurrentViewNameRepairStep - - calendar diff --git a/lib/RepairSteps/CurrentViewNameRepairStep.php b/lib/RepairSteps/CurrentViewNameRepairStep.php deleted file mode 100644 index 58c691297..000000000 --- a/lib/RepairSteps/CurrentViewNameRepairStep.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with this library. If not, see . - * - */ -namespace OCA\Calendar\RepairSteps; - -use OCP\IConfig; -use OCP\IUser; -use OCP\IUserManager; -use OCP\Migration\IOutput; -use OCP\Migration\IRepairStep; - -/** - * Class CurrentViewNameRepairStep - * - * @package OCA\Calendar\RepairSteps - */ -class CurrentViewNameRepairStep implements IRepairStep { - - /** @var IUserManager */ - private $userManager; - - /** @var IConfig */ - private $config; - - /** - * CurrentViewNameRepairStep constructor. - * - * @param IUserManager $userManager - * @param IConfig $config - */ - public function __construct(IUserManager $userManager, - IConfig $config) { - $this->userManager = $userManager; - $this->config = $config; - } - - /** - * @return string - */ - public function getName():string { - return 'Update name of the stored view'; - } - - /** - * @param IOutput $output - */ - public function run(IOutput $output):void { - $this->userManager->callForSeenUsers(function (IUser $user) { - $userId = $user->getUID(); - $savedView = $this->config->getUserValue($userId, 'calendar', 'currentView', null); - - if ($savedView === null) { - return; - } - if (\in_array($savedView, ['timeGridDay', 'timeGridWeek', 'dayGridMonth'], true)) { - return; - } - - switch ($savedView) { - case 'agendaDay': - $this->config->setUserValue($userId, 'calendar', 'currentView', 'timeGridDay'); - break; - - case 'agendaWeek': - $this->config->setUserValue($userId, 'calendar', 'currentView', 'timeGridWeek'); - break; - - case 'month': - default: - $this->config->setUserValue($userId, 'calendar', 'currentView', 'dayGridMonth'); - break; - } - }); - } -} diff --git a/tests/php/unit/RepairSteps/CurrentViewNameRepairStepTest.php b/tests/php/unit/RepairSteps/CurrentViewNameRepairStepTest.php deleted file mode 100644 index 919b8122f..000000000 --- a/tests/php/unit/RepairSteps/CurrentViewNameRepairStepTest.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with this library. If not, see . - * - */ -namespace OCA\Calendar\RepairSteps; - -use OCP\IConfig; -use OCP\IUser; -use OCP\IUserManager; -use OCP\Migration\IOutput; -use ChristophWurst\Nextcloud\Testing\TestCase; - -class CurrentViewNameRepairStepTest extends TestCase { - - /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */ - private $userManager; - - /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ - private $config; - - /** @var CurrentViewNameRepairStep */ - private $repairStep; - - protected function setUp():void { - parent::setUp(); - - $this->userManager = $this->createMock(IUserManager::class); - $this->config = $this->createMock(IConfig::class); - - $this->repairStep = new CurrentViewNameRepairStep($this->userManager, - $this->config); - } - - public function testGetName():void { - $this->assertEquals('Update name of the stored view', $this->repairStep->getName()); - } - - public function testRun():void { - $this->userManager->expects($this->once()) - ->method('callForSeenUsers') - ->with($this->callback(function ($fn) { - $user1 = $this->createMock(IUser::class); - $user1->method('getUID')->willReturn('user1'); - - $user2 = $this->createMock(IUser::class); - $user2->method('getUID')->willReturn('user2'); - - $user3 = $this->createMock(IUser::class); - $user3->method('getUID')->willReturn('user3'); - - $user4 = $this->createMock(IUser::class); - $user4->method('getUID')->willReturn('user4'); - - $user5 = $this->createMock(IUser::class); - $user5->method('getUID')->willReturn('user5'); - - $user6 = $this->createMock(IUser::class); - $user6->method('getUID')->willReturn('user6'); - - $user7 = $this->createMock(IUser::class); - $user7->method('getUID')->willReturn('user7'); - - $user8 = $this->createMock(IUser::class); - $user8->method('getUID')->willReturn('user8'); - - $fn($user1); - $fn($user2); - $fn($user3); - $fn($user4); - $fn($user5); - $fn($user6); - $fn($user7); - $fn($user8); - - return true; - })); - - $this->config - ->method('getUserValue') - ->willReturnMap([ - ['user1', 'calendar', 'currentView', null, 'agendaDay'], - ['user2', 'calendar', 'currentView', null, 'agendaWeek'], - ['user3', 'calendar', 'currentView', null, 'month'], - ['user4', 'calendar', 'currentView', null, 'otherView'], - ['user5', 'calendar', 'currentView', null, null], - ['user7', 'calendar', 'currentView', null, 'timeGridWeek'], - ]); - $this->config - ->method('setUserValue') - ->withConsecutive( - ['user1', 'calendar', 'currentView', 'timeGridDay'], - ['user2', 'calendar', 'currentView', 'timeGridWeek'], - ['user3', 'calendar', 'currentView', 'dayGridMonth'], - ['user4', 'calendar', 'currentView', 'dayGridMonth'], - ['user6', 'calendar', 'currentView', null], - ['user8', 'calendar', 'currentView', null, 'dayGridMonth'] - ); - - $output = $this->createMock(IOutput::class); - $output->expects($this->never()) - ->method($this->anything()); - - $this->repairStep->run($output); - } -}