Skip to content

Commit ea29e2f

Browse files
committed
test: adjust tests for changed controller
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent cf9d52b commit ea29e2f

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

tests/Unit/Controller/PageControllerTest.php

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,41 @@
1212

1313
namespace OCA\Maps\Controller;
1414

15-
use OCA\Maps\AppInfo\Application;
1615
use OCP\AppFramework\Http\TemplateResponse;
16+
use OCP\AppFramework\Services\IInitialState;
1717
use OCP\EventDispatcher\IEventDispatcher;
18-
use OCP\IServerContainer;
18+
use OCP\IConfig;
19+
use OCP\IRequest;
20+
use OCP\IURLGenerator;
21+
use PHPUnit\Framework\MockObject\MockObject;
1922

2023
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;
24+
private PageController $controller;
25+
private string $userId = 'john';
26+
private IConfig&MockObject $config;
27+
private IInitialState&MockObject $initialState;
28+
private IEventDispatcher&MockObject $eventDispatcher;
29+
private IURLGenerator&MockObject $urlGenerator;
2730

2831
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');
32+
/** @var IRequest&MockObject */
33+
$request = $this->createMock(IRequest::class);
34+
$this->config = $this->createMock(IConfig::class);
35+
$this->initialState = $this->createMock(IInitialState::class);
36+
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
37+
$this->urlGenerator = $this->createMock(IURLGenerator::class);
3938

4039
$this->controller = new PageController(
41-
'maps', $request, $this->eventDispatcher, $this->config, $initialStateService, $this->userId
40+
'maps',
41+
$request,
42+
$this->userId,
43+
$this->eventDispatcher,
44+
$this->config,
45+
$this->initialState,
46+
$this->urlGenerator,
4247
);
4348
}
4449

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

0 commit comments

Comments
 (0)