AdminTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\User_LDAP\Tests\Settings;
  7. use OCA\User_LDAP\Configuration;
  8. use OCA\User_LDAP\Settings\Admin;
  9. use OCP\AppFramework\Http\TemplateResponse;
  10. use OCP\IL10N;
  11. use OCP\Template;
  12. use Test\TestCase;
  13. /**
  14. * @group DB
  15. * @package OCA\User_LDAP\Tests\Settings
  16. */
  17. class AdminTest extends TestCase {
  18. /** @var Admin */
  19. private $admin;
  20. /** @var IL10N */
  21. private $l10n;
  22. protected function setUp(): void {
  23. parent::setUp();
  24. $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
  25. $this->admin = new Admin(
  26. $this->l10n
  27. );
  28. }
  29. /**
  30. * @UseDB
  31. */
  32. public function testGetForm(): void {
  33. $prefixes = ['s01'];
  34. $hosts = ['s01' => ''];
  35. $wControls = new Template('user_ldap', 'part.wizardcontrols');
  36. $wControls = $wControls->fetchPage();
  37. $sControls = new Template('user_ldap', 'part.settingcontrols');
  38. $sControls = $sControls->fetchPage();
  39. $parameters['serverConfigurationPrefixes'] = $prefixes;
  40. $parameters['serverConfigurationHosts'] = $hosts;
  41. $parameters['settingControls'] = $sControls;
  42. $parameters['wizardControls'] = $wControls;
  43. // assign default values
  44. $config = new Configuration('', false);
  45. $defaults = $config->getDefaults();
  46. foreach ($defaults as $key => $default) {
  47. $parameters[$key . '_default'] = $default;
  48. }
  49. $expected = new TemplateResponse('user_ldap', 'settings', $parameters);
  50. $this->assertEquals($expected, $this->admin->getForm());
  51. }
  52. public function testGetSection(): void {
  53. $this->assertSame('ldap', $this->admin->getSection());
  54. }
  55. public function testGetPriority(): void {
  56. $this->assertSame(5, $this->admin->getPriority());
  57. }
  58. }