]> source.dussan.org Git - nextcloud-server.git/commitdiff
Properly inject EventDispatched in BackgroundRepair 14805/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Fri, 22 Mar 2019 09:29:36 +0000 (10:29 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 22 Mar 2019 09:29:36 +0000 (10:29 +0100)
Else it will just be null when called

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
lib/private/Migration/BackgroundRepair.php
tests/lib/Migration/BackgroundRepairTest.php

index a873d23e7b25a7caee09c1806989e27ced22692f..7ef90301cf3c7dbcafac3df2eabd638aac4ae25c 100644 (file)
@@ -47,10 +47,7 @@ class BackgroundRepair extends TimedJob {
        /** @var EventDispatcherInterface */
        private $dispatcher;
 
-       /**
-        * @param EventDispatcherInterface $dispatcher
-        */
-       public function setDispatcher(EventDispatcherInterface $dispatcher): void {
+       public function __construct(EventDispatcherInterface $dispatcher) {
                $this->dispatcher = $dispatcher;
        }
 
index 180ce72d315b997821340f7add803210304a0063..df81fd45772d78bdf97a2cdea856889abfd320be 100644 (file)
@@ -77,12 +77,11 @@ class BackgroundRepairTest extends TestCase {
                $this->logger = $this->getMockBuilder(ILogger::class)
                        ->disableOriginalConstructor()
                        ->getMock();
+               $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
                $this->job = $this->getMockBuilder(BackgroundRepair::class)
+                       ->setConstructorArgs([$this->dispatcher])
                        ->setMethods(['loadApp'])
                        ->getMock();
-
-               $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
-               $this->job->setDispatcher($this->dispatcher);
        }
 
        public function testNoArguments() {