AdminSettingsControllerTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Lukas Reschke <lukas@statuscode.ch>
  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\Settings\Controller;
  24. use OC\Settings\Admin\TipsTricks;
  25. use OC\Settings\Controller\AdminSettingsController;
  26. use OCP\AppFramework\Http\TemplateResponse;
  27. use OCP\INavigationManager;
  28. use OCP\IRequest;
  29. use OCP\Settings\IManager;
  30. use Test\TestCase;
  31. class AdminSettingsControllerTest extends TestCase {
  32. /** @var AdminSettingsController */
  33. private $adminSettingsController;
  34. /** @var IRequest */
  35. private $request;
  36. /** @var INavigationManager */
  37. private $navigationManager;
  38. /** @var IManager */
  39. private $settingsManager;
  40. public function setUp() {
  41. parent::setUp();
  42. $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
  43. $this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->getMock();
  44. $this->settingsManager = $this->getMockBuilder('\OCP\Settings\IManager')->getMock();
  45. $this->adminSettingsController = new AdminSettingsController(
  46. 'settings',
  47. $this->request,
  48. $this->navigationManager,
  49. $this->settingsManager
  50. );
  51. }
  52. public function testIndex() {
  53. $this->settingsManager
  54. ->expects($this->once())
  55. ->method('getAdminSections')
  56. ->willReturn([]);
  57. $this->settingsManager
  58. ->expects($this->once())
  59. ->method('getAdminSettings')
  60. ->with('test')
  61. ->willReturn([5 => new TipsTricks($this->getMockBuilder('\OCP\IConfig')->getMock())]);
  62. $expected = new TemplateResponse('settings', 'admin/frame', ['forms' => [], 'content' => '']);
  63. $this->assertEquals($expected, $this->adminSettingsController->index('test'));
  64. }
  65. }