Skip to content

Commit 4847340

Browse files
committed
Fix BackgroundRepairTest
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent c3dab68 commit 4847340

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

tests/lib/Migration/BackgroundRepairTest.php

+16-14
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121

2222
namespace Test\Migration;
2323

24-
use OC\Migration\BackgroundRepair;
25-
use OC\NeedsUpdateException;
2624
use OCP\AppFramework\Utility\ITimeFactory;
25+
use OCP\EventDispatcher\IEventDispatcher;
2726
use OCP\Migration\IOutput;
2827
use OCP\Migration\IRepairStep;
29-
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
30-
use Symfony\Component\EventDispatcher\GenericEvent;
31-
use Test\TestCase;
28+
use OC\BackgroundJob\JobList;
29+
use OC\Migration\BackgroundRepair;
30+
use OC\NeedsUpdateException;
31+
use OC\Repair\Events\RepairStepEvent;
32+
use PHPUnit\Framework\MockObject\MockObject;
3233
use Psr\Log\LoggerInterface;
34+
use Test\TestCase;
3335

3436
class TestRepairStep implements IRepairStep {
3537

@@ -57,16 +59,16 @@ public function run(IOutput $output) {
5759

5860
class BackgroundRepairTest extends TestCase {
5961

60-
/** @var \OC\BackgroundJob\JobList|\PHPUnit\Framework\MockObject\MockObject */
62+
/** @var JobList|MockObject */
6163
private $jobList;
6264

63-
/** @var BackgroundRepair|\PHPUnit\Framework\MockObject\MockObject */
65+
/** @var BackgroundRepair|MockObject */
6466
private $job;
6567

66-
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
68+
/** @var LoggerInterface|MockObject */
6769
private $logger;
6870

69-
/** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject $dispatcher */
71+
/** @var IEventDispatcher|MockObject $dispatcher */
7072
private $dispatcher;
7173

7274
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject $dispatcher */
@@ -75,13 +77,13 @@ class BackgroundRepairTest extends TestCase {
7577
protected function setUp(): void {
7678
parent::setUp();
7779

78-
$this->jobList = $this->getMockBuilder('OC\BackgroundJob\JobList')
80+
$this->jobList = $this->getMockBuilder(JobList::class)
7981
->disableOriginalConstructor()
8082
->getMock();
8183
$this->logger = $this->getMockBuilder(LoggerInterface::class)
8284
->disableOriginalConstructor()
8385
->getMock();
84-
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
86+
$this->dispatcher = $this->createMock(IEventDispatcher::class);
8587
$this->time = $this->createMock(ITimeFactory::class);
8688
$this->time->method('getTime')
8789
->willReturn(999999);
@@ -107,7 +109,7 @@ public function testAppUpgrading() {
107109
}
108110

109111
public function testUnknownStep() {
110-
$this->dispatcher->expects($this->never())->method('dispatch');
112+
$this->dispatcher->expects($this->never())->method('dispatchTyped');
111113

112114
$this->jobList->expects($this->once())->method('remove');
113115
$this->logger->expects($this->once())->method('error');
@@ -120,8 +122,8 @@ public function testUnknownStep() {
120122
}
121123

122124
public function testWorkingStep() {
123-
$this->dispatcher->expects($this->once())->method('dispatch')
124-
->with('\OC\Repair::step', new GenericEvent('\OC\Repair::step', ['A test repair step']));
125+
$this->dispatcher->expects($this->once())->method('dispatchTyped')
126+
->with($this->equalTo(new RepairStepEvent('A test repair step')));
125127

126128
$this->jobList->expects($this->once())->method('remove');
127129

0 commit comments

Comments
 (0)