AdminTest.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 OCA\User_LDAP\Tests\Settings;
  24. use OCA\User_LDAP\Configuration;
  25. use OCA\User_LDAP\Helper;
  26. use OCA\User_LDAP\Settings\Admin;
  27. use OCP\AppFramework\Http\TemplateResponse;
  28. use OCP\IL10N;
  29. use OCP\Template;
  30. use Test\TestCase;
  31. /**
  32. * @group DB
  33. * @package OCA\User_LDAP\Tests\Settings
  34. */
  35. class AdminTest extends TestCase {
  36. /** @var Admin */
  37. private $admin;
  38. /** @var IL10N */
  39. private $l10n;
  40. public function setUp() {
  41. parent::setUp();
  42. $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
  43. $this->admin = new Admin(
  44. $this->l10n
  45. );
  46. }
  47. /**
  48. * @UseDB
  49. */
  50. public function testGetForm() {
  51. $helper = new Helper(\OC::$server->getConfig());
  52. $prefixes = $helper->getServerConfigurationPrefixes();
  53. $hosts = $helper->getServerConfigurationHosts();
  54. $wControls = new Template('user_ldap', 'part.wizardcontrols');
  55. $wControls = $wControls->fetchPage();
  56. $sControls = new Template('user_ldap', 'part.settingcontrols');
  57. $sControls = $sControls->fetchPage();
  58. $parameters['serverConfigurationPrefixes'] = $prefixes;
  59. $parameters['serverConfigurationHosts'] = $hosts;
  60. $parameters['settingControls'] = $sControls;
  61. $parameters['wizardControls'] = $wControls;
  62. // assign default values
  63. $config = new Configuration('', false);
  64. $defaults = $config->getDefaults();
  65. foreach($defaults as $key => $default) {
  66. $parameters[$key.'_default'] = $default;
  67. }
  68. $expected = new TemplateResponse('user_ldap', 'settings', $parameters);
  69. $this->assertEquals($expected, $this->admin->getForm());
  70. }
  71. public function testGetSection() {
  72. $this->assertSame('ldap', $this->admin->getSection());
  73. }
  74. public function testGetPriority() {
  75. $this->assertSame(5, $this->admin->getPriority());
  76. }
  77. }