diff options
Diffstat (limited to 'tests/lib/Migration/BackgroundRepairTest.php')
-rw-r--r-- | tests/lib/Migration/BackgroundRepairTest.php | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/tests/lib/Migration/BackgroundRepairTest.php b/tests/lib/Migration/BackgroundRepairTest.php index 585ebc420ad..5bc085eb7ec 100644 --- a/tests/lib/Migration/BackgroundRepairTest.php +++ b/tests/lib/Migration/BackgroundRepairTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -9,9 +10,9 @@ namespace Test\Migration; use OC\BackgroundJob\JobList; use OC\Migration\BackgroundRepair; -use OC\NeedsUpdateException; use OC\Repair; use OC\Repair\Events\RepairStepEvent; +use OCP\App\IAppManager; use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; use OCP\Migration\IOutput; @@ -48,26 +49,21 @@ class BackgroundRepairTest extends TestCase { private LoggerInterface $logger; private IEventDispatcher $dispatcher; private ITimeFactory $time; + private IAppManager $appManager; private Repair $repair; protected function setUp(): void { parent::setUp(); - $this->jobList = $this->getMockBuilder(JobList::class) - ->disableOriginalConstructor() - ->getMock(); - $this->logger = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); + $this->jobList = $this->createMock(JobList::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->dispatcher = $this->createMock(IEventDispatcher::class); $this->time = $this->createMock(ITimeFactory::class); $this->time->method('getTime') ->willReturn(999999); + $this->appManager = $this->createMock(IAppManager::class); $this->repair = new Repair($this->dispatcher, $this->logger); - $this->job = $this->getMockBuilder(BackgroundRepair::class) - ->setConstructorArgs([$this->repair, $this->time, $this->logger, $this->jobList]) - ->setMethods(['loadApp']) - ->getMock(); + $this->job = new BackgroundRepair($this->repair, $this->time, $this->logger, $this->jobList, $this->appManager); } public function testNoArguments(): void { @@ -75,16 +71,6 @@ class BackgroundRepairTest extends TestCase { $this->job->start($this->jobList); } - public function testAppUpgrading(): void { - $this->jobList->expects($this->never())->method('remove'); - $this->job->expects($this->once())->method('loadApp')->with('test')->willThrowException(new NeedsUpdateException()); - $this->job->setArgument([ - 'app' => 'test', - 'step' => 'j' - ]); - $this->job->start($this->jobList); - } - public function testUnknownStep(): void { $this->dispatcher->expects($this->never())->method('dispatchTyped'); @@ -103,6 +89,9 @@ class BackgroundRepairTest extends TestCase { ->with($this->equalTo(new RepairStepEvent('A test repair step'))); $this->jobList->expects($this->once())->method('remove'); + $this->appManager->expects(self::once()) + ->method('loadApp') + ->with('test'); $this->job->setArgument([ 'app' => 'test', |