|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @copyright Copyright (c) 2018 Julius Härtl <[email protected]> |
| 4 | + * |
| 5 | + * @author Julius Härtl <[email protected]> |
| 6 | + * |
| 7 | + * @license GNU AGPL version 3 or any later version |
| 8 | + * |
| 9 | + * This program is free software: you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU Affero General Public License as |
| 11 | + * published by the Free Software Foundation, either version 3 of the |
| 12 | + * License, or (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU Affero General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU Affero General Public License |
| 20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | + * |
| 22 | + */ |
| 23 | +namespace Tests\Core\Controller; |
| 24 | + |
| 25 | +use OC\Core\Controller\NavigationController; |
| 26 | +use OCP\AppFramework\Http\JSONResponse; |
| 27 | +use OCP\INavigationManager; |
| 28 | +use OCP\IRequest; |
| 29 | +use Test\TestCase; |
| 30 | + |
| 31 | +class NavigationControllerTest extends TestCase { |
| 32 | + |
| 33 | + /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ |
| 34 | + private $request; |
| 35 | + |
| 36 | + /** @var INavigationManager|\PHPUnit_Framework_MockObject_MockObject */ |
| 37 | + private $navigationManager; |
| 38 | + |
| 39 | + /** @var NavigationController */ |
| 40 | + private $controller; |
| 41 | + |
| 42 | + public function setUp() { |
| 43 | + parent::setUp(); |
| 44 | + |
| 45 | + |
| 46 | + $this->request = $this->createMock(IRequest::class); |
| 47 | + $this->navigationManager = $this->createMock(INavigationManager::class); |
| 48 | + |
| 49 | + $this->controller = new NavigationController( |
| 50 | + 'core', |
| 51 | + $this->request, |
| 52 | + $this->navigationManager |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + public function dataGetNavigation() { |
| 57 | + return [ |
| 58 | + [false], [true] |
| 59 | + ]; |
| 60 | + } |
| 61 | + /** @dataProvider dataGetNavigation */ |
| 62 | + public function testGetAppNavigation($absolute) { |
| 63 | + $this->navigationManager->expects($this->once()) |
| 64 | + ->method('getAll') |
| 65 | + ->with('link', $absolute); |
| 66 | + $this->assertInstanceOf(JSONResponse::class, $this->controller->getAppsNavigation($absolute)); |
| 67 | + } |
| 68 | + |
| 69 | + /** @dataProvider dataGetNavigation */ |
| 70 | + public function testGetSettingsNavigation($absolute) { |
| 71 | + $this->navigationManager->expects($this->once()) |
| 72 | + ->method('getAll') |
| 73 | + ->with('settings', $absolute); |
| 74 | + $this->assertInstanceOf(JSONResponse::class, $this->controller->getSettingsNavigation($absolute)); |
| 75 | + } |
| 76 | + |
| 77 | +} |
0 commit comments