1
0

AdminTest.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\User_LDAP\Tests\Settings;
  27. use OCA\User_LDAP\Configuration;
  28. use OCA\User_LDAP\Settings\Admin;
  29. use OCP\AppFramework\Http\TemplateResponse;
  30. use OCP\IL10N;
  31. use OCP\Template;
  32. use Test\TestCase;
  33. /**
  34. * @group DB
  35. * @package OCA\User_LDAP\Tests\Settings
  36. */
  37. class AdminTest extends TestCase {
  38. /** @var Admin */
  39. private $admin;
  40. /** @var IL10N */
  41. private $l10n;
  42. protected function setUp(): void {
  43. parent::setUp();
  44. $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
  45. $this->admin = new Admin(
  46. $this->l10n
  47. );
  48. }
  49. /**
  50. * @UseDB
  51. */
  52. public function testGetForm() {
  53. $prefixes = ['s01'];
  54. $hosts = ['s01' => ''];
  55. $wControls = new Template('user_ldap', 'part.wizardcontrols');
  56. $wControls = $wControls->fetchPage();
  57. $sControls = new Template('user_ldap', 'part.settingcontrols');
  58. $sControls = $sControls->fetchPage();
  59. $parameters['serverConfigurationPrefixes'] = $prefixes;
  60. $parameters['serverConfigurationHosts'] = $hosts;
  61. $parameters['settingControls'] = $sControls;
  62. $parameters['wizardControls'] = $wControls;
  63. // assign default values
  64. $config = new Configuration('', false);
  65. $defaults = $config->getDefaults();
  66. foreach($defaults as $key => $default) {
  67. $parameters[$key.'_default'] = $default;
  68. }
  69. $expected = new TemplateResponse('user_ldap', 'settings', $parameters);
  70. $this->assertEquals($expected, $this->admin->getForm());
  71. }
  72. public function testGetSection() {
  73. $this->assertSame('ldap', $this->admin->getSection());
  74. }
  75. public function testGetPriority() {
  76. $this->assertSame(5, $this->admin->getPriority());
  77. }
  78. }