21
21
22
22
namespace Test \Migration ;
23
23
24
- use OC \Migration \BackgroundRepair ;
25
- use OC \NeedsUpdateException ;
26
24
use OCP \AppFramework \Utility \ITimeFactory ;
25
+ use OCP \EventDispatcher \IEventDispatcher ;
27
26
use OCP \Migration \IOutput ;
28
27
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 ;
32
33
use Psr \Log \LoggerInterface ;
34
+ use Test \TestCase ;
33
35
34
36
class TestRepairStep implements IRepairStep {
35
37
@@ -57,16 +59,16 @@ public function run(IOutput $output) {
57
59
58
60
class BackgroundRepairTest extends TestCase {
59
61
60
- /** @var \OC\BackgroundJob\ JobList|\PHPUnit\Framework\MockObject\ MockObject */
62
+ /** @var JobList|MockObject */
61
63
private $ jobList ;
62
64
63
- /** @var BackgroundRepair|\PHPUnit\Framework\MockObject\ MockObject */
65
+ /** @var BackgroundRepair|MockObject */
64
66
private $ job ;
65
67
66
- /** @var LoggerInterface|\PHPUnit\Framework\MockObject\ MockObject */
68
+ /** @var LoggerInterface|MockObject */
67
69
private $ logger ;
68
70
69
- /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\ MockObject $dispatcher */
71
+ /** @var IEventDispatcher| MockObject $dispatcher */
70
72
private $ dispatcher ;
71
73
72
74
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject $dispatcher */
@@ -75,13 +77,13 @@ class BackgroundRepairTest extends TestCase {
75
77
protected function setUp (): void {
76
78
parent ::setUp ();
77
79
78
- $ this ->jobList = $ this ->getMockBuilder (' OC\BackgroundJob\ JobList' )
80
+ $ this ->jobList = $ this ->getMockBuilder (JobList::class )
79
81
->disableOriginalConstructor ()
80
82
->getMock ();
81
83
$ this ->logger = $ this ->getMockBuilder (LoggerInterface::class)
82
84
->disableOriginalConstructor ()
83
85
->getMock ();
84
- $ this ->dispatcher = $ this ->createMock (EventDispatcherInterface ::class);
86
+ $ this ->dispatcher = $ this ->createMock (IEventDispatcher ::class);
85
87
$ this ->time = $ this ->createMock (ITimeFactory::class);
86
88
$ this ->time ->method ('getTime ' )
87
89
->willReturn (999999 );
@@ -107,7 +109,7 @@ public function testAppUpgrading() {
107
109
}
108
110
109
111
public function testUnknownStep () {
110
- $ this ->dispatcher ->expects ($ this ->never ())->method ('dispatch ' );
112
+ $ this ->dispatcher ->expects ($ this ->never ())->method ('dispatchTyped ' );
111
113
112
114
$ this ->jobList ->expects ($ this ->once ())->method ('remove ' );
113
115
$ this ->logger ->expects ($ this ->once ())->method ('error ' );
@@ -120,8 +122,8 @@ public function testUnknownStep() {
120
122
}
121
123
122
124
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 ') ));
125
127
126
128
$ this ->jobList ->expects ($ this ->once ())->method ('remove ' );
127
129
0 commit comments