GenericTest.php 3.2 KB

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