repair step removed

Signed-off-by: Avinash Gusain <avinashg@e.email>
This commit is contained in:
Avinash Gusain 2022-10-27 21:22:30 +05:30
parent fd86c3729e
commit 2c084474ba
3 changed files with 0 additions and 225 deletions

View File

@ -38,11 +38,6 @@
<background-jobs>
<job>OCA\Calendar\BackgroundJob\CleanUpOutdatedBookingsJob</job>
</background-jobs>
<repair-steps>
<post-migration>
<step>OCA\Calendar\RepairSteps\CurrentViewNameRepairStep</step>
</post-migration>
</repair-steps>
<navigations>
<navigation>
<id>calendar</id>

View File

@ -1,96 +0,0 @@
<?php
declare(strict_types=1);
/**
* Calendar App
*
* @author Georg Ehrke
*
* @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
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;
}
});
}
}

View File

@ -1,124 +0,0 @@
<?php
declare(strict_types=1);
/**
* Calendar App
*
* @author Georg Ehrke
* @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
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);
}
}