SecurityFilterTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  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\Settings\Tests;
  25. use OCA\Settings\Activity\SecurityFilter;
  26. use OCP\IL10N;
  27. use OCP\IURLGenerator;
  28. use PHPUnit\Framework\MockObject\MockObject;
  29. use Test\TestCase;
  30. class SecurityFilterTest extends TestCase {
  31. /** @var IURLGenerator|MockObject */
  32. private $urlGenerator;
  33. /** @var IL10N|MockObject */
  34. private $l10n;
  35. /** @var SecurityFilter */
  36. private $filter;
  37. protected function setUp(): void {
  38. parent::setUp();
  39. $this->urlGenerator = $this->createMock(IURLGenerator::class);
  40. $this->l10n = $this->createMock(IL10N::class);
  41. $this->filter = new SecurityFilter($this->urlGenerator, $this->l10n);
  42. }
  43. public function testAllowedApps() {
  44. $this->assertEquals([], $this->filter->allowedApps());
  45. }
  46. public function testFilterTypes() {
  47. $this->assertEquals(['security'], $this->filter->filterTypes(['comments', 'security']));
  48. }
  49. public function testGetIcon() {
  50. $this->urlGenerator->expects($this->once())
  51. ->method('imagePath')
  52. ->with('core', 'actions/password.svg')
  53. ->willReturn('path/to/icon.svg');
  54. $this->urlGenerator->expects($this->once())
  55. ->method('getAbsoluteURL')
  56. ->with('path/to/icon.svg')
  57. ->willReturn('abs/path/to/icon.svg');
  58. $this->assertEquals('abs/path/to/icon.svg', $this->filter->getIcon());
  59. }
  60. public function testGetIdentifier() {
  61. $this->assertEquals('security', $this->filter->getIdentifier());
  62. }
  63. public function testGetName() {
  64. $this->l10n->expects($this->once())
  65. ->method('t')
  66. ->with('Security')
  67. ->willReturn('translated');
  68. $this->assertEquals('translated', $this->filter->getName());
  69. }
  70. public function testGetPriority() {
  71. $this->assertEquals(30, $this->filter->getPriority());
  72. }
  73. }