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