Skip to content

Commit ee324b7

Browse files
committed
test: adjust tests for changed controller
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent cf9d52b commit ee324b7

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

tests/Unit/Controller/PageControllerTest.php

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,41 @@
1414

1515
use OCA\Maps\AppInfo\Application;
1616
use OCP\AppFramework\Http\TemplateResponse;
17+
use OCP\AppFramework\Services\IInitialState;
1718
use OCP\EventDispatcher\IEventDispatcher;
19+
use OCP\IConfig;
20+
use OCP\IRequest;
1821
use OCP\IServerContainer;
22+
use OCP\IURLGenerator;
23+
use PHPUnit\Framework\MockObject\MockObject;
1924

2025
class PageControllerTest extends \PHPUnit\Framework\TestCase {
21-
private $controller;
22-
private $userId = 'john';
23-
private $config;
24-
private $eventDispatcher;
25-
private $app;
26-
private $container;
26+
private PageController $controller;
27+
private string $userId = 'john';
28+
private IConfig&MockObject $config;
29+
private IInitialState&MockObject $initialState;
30+
private IEventDispatcher&MockObject $eventDispatcher;
31+
private IURLGenerator&MockObject $urlGenerator;
2732

2833
protected function setUp(): void {
29-
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
30-
$initialStateService = $this->getMockBuilder('OCP\IInitialStateService')->getMock();
31-
$this->app = new Application();
32-
$this->container = $this->app->getContainer();
33-
$c = $this->container;
34-
$this->config = $c->query(IServerContainer::class)->getConfig();
35-
$this->eventDispatcher = $c->query(IServerContainer::class)->query(IEventDispatcher::class);
36-
37-
$this->oldGHValue = $this->config->getAppValue('maps', 'graphhopperURL');
38-
$this->config->setAppValue('maps', 'graphhopperURL', 'https://graphhopper.com:8080');
34+
/** @var IRequest&MockObject */
35+
$request = $this->createMock(IRequest::class);
36+
$this->config = $this->createMock(IConfig::class);
37+
$this->initialState = $this->createMock(IInitialState::class);
38+
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
39+
$this->urlGenerator = $this->createMock(IURLGenerator::class);
3940

4041
$this->controller = new PageController(
41-
'maps', $request, $this->eventDispatcher, $this->config, $initialStateService, $this->userId
42+
'maps',
43+
$request,
44+
$this->userId,
45+
$this->eventDispatcher,
46+
$this->config,
47+
$this->initialState,
48+
$this->urlGenerator,
4249
);
4350
}
4451

45-
protected function tearDown(): void {
46-
$this->config->setAppValue('maps', 'graphhopperURL', $this->oldGHValue);
47-
}
48-
4952
public function testIndex() {
5053
$result = $this->controller->index();
5154

0 commit comments

Comments
 (0)