|
12 | 12 |
|
13 | 13 | namespace OCA\Maps\Controller; |
14 | 14 |
|
15 | | -use OCA\Maps\AppInfo\Application; |
16 | 15 | use OCP\AppFramework\Http\TemplateResponse; |
| 16 | +use OCP\AppFramework\Services\IInitialState; |
17 | 17 | 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; |
19 | 22 |
|
20 | 23 | 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; |
27 | 30 |
|
28 | 31 | 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); |
39 | 38 |
|
40 | 39 | $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, |
42 | 47 | ); |
43 | 48 | } |
44 | 49 |
|
45 | | - protected function tearDown(): void { |
46 | | - $this->config->setAppValue('maps', 'graphhopperURL', $this->oldGHValue); |
47 | | - } |
48 | | - |
49 | 50 | public function testIndex() { |
50 | 51 | $result = $this->controller->index(); |
51 | 52 |
|
|
0 commit comments