|
14 | 14 |
|
15 | 15 | use OCA\Maps\AppInfo\Application; |
16 | 16 | use OCP\AppFramework\Http\TemplateResponse; |
| 17 | +use OCP\AppFramework\Services\IInitialState; |
17 | 18 | use OCP\EventDispatcher\IEventDispatcher; |
| 19 | +use OCP\IConfig; |
| 20 | +use OCP\IRequest; |
18 | 21 | use OCP\IServerContainer; |
| 22 | +use OCP\IURLGenerator; |
| 23 | +use PHPUnit\Framework\MockObject\MockObject; |
19 | 24 |
|
20 | 25 | 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; |
27 | 32 |
|
28 | 33 | 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); |
39 | 40 |
|
40 | 41 | $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, |
42 | 49 | ); |
43 | 50 | } |
44 | 51 |
|
45 | | - protected function tearDown(): void { |
46 | | - $this->config->setAppValue('maps', 'graphhopperURL', $this->oldGHValue); |
47 | | - } |
48 | | - |
49 | 52 | public function testIndex() { |
50 | 53 | $result = $this->controller->index(); |
51 | 54 |
|
|
0 commit comments