1
0

SectionTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Valdnet <47037905+Valdnet@users.noreply.github.com>
  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\Settings\Section;
  29. use OCP\IL10N;
  30. use OCP\IURLGenerator;
  31. use Test\TestCase;
  32. class SectionTest extends TestCase {
  33. /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
  34. private $url;
  35. /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
  36. private $l;
  37. /** @var Section */
  38. private $section;
  39. protected function setUp(): void {
  40. parent::setUp();
  41. $this->url = $this->createMock(IURLGenerator::class);
  42. $this->l = $this->createMock(IL10N::class);
  43. $this->section = new Section(
  44. $this->url,
  45. $this->l
  46. );
  47. }
  48. public function testGetID() {
  49. $this->assertSame('ldap', $this->section->getID());
  50. }
  51. public function testGetName() {
  52. $this->l
  53. ->expects($this->once())
  54. ->method('t')
  55. ->with('LDAP/AD integration')
  56. ->willReturn('LDAP/AD integration');
  57. $this->assertSame('LDAP/AD integration', $this->section->getName());
  58. }
  59. public function testGetPriority() {
  60. $this->assertSame(25, $this->section->getPriority());
  61. }
  62. public function testGetIcon() {
  63. $this->url->expects($this->once())
  64. ->method('imagePath')
  65. ->with('user_ldap', 'app-dark.svg')
  66. ->willReturn('icon');
  67. $this->assertSame('icon', $this->section->getIcon());
  68. }
  69. }