GenericTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  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\DAV\Tests\unit\CalDAV\Activity\Filter;
  24. use OCA\DAV\CalDAV\Activity\Filter\Calendar;
  25. use OCA\DAV\CalDAV\Activity\Filter\Todo;
  26. use OCP\Activity\IFilter;
  27. use Test\TestCase;
  28. /**
  29. * @group DB
  30. */
  31. class GenericTest extends TestCase {
  32. public function dataFilters() {
  33. return [
  34. [Calendar::class],
  35. [Todo::class],
  36. ];
  37. }
  38. /**
  39. * @dataProvider dataFilters
  40. * @param string $filterClass
  41. */
  42. public function testImplementsInterface($filterClass) {
  43. $filter = \OC::$server->query($filterClass);
  44. $this->assertInstanceOf(IFilter::class, $filter);
  45. }
  46. /**
  47. * @dataProvider dataFilters
  48. * @param string $filterClass
  49. */
  50. public function testGetIdentifier($filterClass) {
  51. /** @var IFilter $filter */
  52. $filter = \OC::$server->query($filterClass);
  53. $this->assertIsString($filter->getIdentifier());
  54. }
  55. /**
  56. * @dataProvider dataFilters
  57. * @param string $filterClass
  58. */
  59. public function testGetName($filterClass) {
  60. /** @var IFilter $filter */
  61. $filter = \OC::$server->query($filterClass);
  62. $this->assertIsString($filter->getName());
  63. }
  64. /**
  65. * @dataProvider dataFilters
  66. * @param string $filterClass
  67. */
  68. public function testGetPriority($filterClass) {
  69. /** @var IFilter $filter */
  70. $filter = \OC::$server->query($filterClass);
  71. $priority = $filter->getPriority();
  72. $this->assertIsInt($filter->getPriority());
  73. $this->assertGreaterThanOrEqual(0, $priority);
  74. $this->assertLessThanOrEqual(100, $priority);
  75. }
  76. /**
  77. * @dataProvider dataFilters
  78. * @param string $filterClass
  79. */
  80. public function testGetIcon($filterClass) {
  81. /** @var IFilter $filter */
  82. $filter = \OC::$server->query($filterClass);
  83. $this->assertIsString($filter->getIcon());
  84. $this->assertStringStartsWith('http', $filter->getIcon());
  85. }
  86. /**
  87. * @dataProvider dataFilters
  88. * @param string $filterClass
  89. */
  90. public function testFilterTypes($filterClass) {
  91. /** @var IFilter $filter */
  92. $filter = \OC::$server->query($filterClass);
  93. $this->assertIsArray($filter->filterTypes([]));
  94. }
  95. /**
  96. * @dataProvider dataFilters
  97. * @param string $filterClass
  98. */
  99. public function testAllowedApps($filterClass) {
  100. /** @var IFilter $filter */
  101. $filter = \OC::$server->query($filterClass);
  102. $this->assertIsArray($filter->allowedApps());
  103. }
  104. }