SectionTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\Theming\Tests\Settings;
  25. use OCA\Theming\Settings\Section;
  26. use OCP\IL10N;
  27. use OCP\IURLGenerator;
  28. use Test\TestCase;
  29. class SectionTest extends TestCase {
  30. /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
  31. private $url;
  32. /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
  33. private $l;
  34. /** @var Section */
  35. private $section;
  36. protected function setUp(): void {
  37. parent::setUp();
  38. $this->url = $this->createMock(IURLGenerator::class);
  39. $this->l = $this->createMock(IL10N::class);
  40. $this->section = new Section(
  41. $this->url,
  42. $this->l
  43. );
  44. }
  45. public function testGetID() {
  46. $this->assertSame('theming', $this->section->getID());
  47. }
  48. public function testGetName() {
  49. $this->l
  50. ->expects($this->once())
  51. ->method('t')
  52. ->with('Theming')
  53. ->willReturn('Theming');
  54. $this->assertSame('Theming', $this->section->getName());
  55. }
  56. public function testGetPriority() {
  57. $this->assertSame(30, $this->section->getPriority());
  58. }
  59. public function testGetIcon() {
  60. $this->url->expects($this->once())
  61. ->method('imagePath')
  62. ->with('theming', 'app-dark.svg')
  63. ->willReturn('icon');
  64. $this->assertSame('icon', $this->section->getIcon());
  65. }
  66. }