GenericTest.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Robin Appelman <robin@icewind.nl>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\Files\Tests\Activity\Setting;
  26. use OCA\Files\Activity\Settings\FavoriteAction;
  27. use OCA\Files\Activity\Settings\FileChanged;
  28. use OCP\Activity\ISetting;
  29. use Test\TestCase;
  30. class GenericTest extends TestCase {
  31. public function dataSettings() {
  32. return [
  33. [FavoriteAction::class],
  34. [FileChanged::class],
  35. [FileChanged::class],
  36. ];
  37. }
  38. /**
  39. * @dataProvider dataSettings
  40. * @param string $settingClass
  41. */
  42. public function testImplementsInterface($settingClass) {
  43. $setting = \OC::$server->query($settingClass);
  44. $this->assertInstanceOf(ISetting::class, $setting);
  45. }
  46. /**
  47. * @dataProvider dataSettings
  48. * @param string $settingClass
  49. */
  50. public function testGetIdentifier($settingClass) {
  51. /** @var ISetting $setting */
  52. $setting = \OC::$server->query($settingClass);
  53. $this->assertIsString($setting->getIdentifier());
  54. }
  55. /**
  56. * @dataProvider dataSettings
  57. * @param string $settingClass
  58. */
  59. public function testGetName($settingClass) {
  60. /** @var ISetting $setting */
  61. $setting = \OC::$server->query($settingClass);
  62. $this->assertIsString($setting->getName());
  63. }
  64. /**
  65. * @dataProvider dataSettings
  66. * @param string $settingClass
  67. */
  68. public function testGetPriority($settingClass) {
  69. /** @var ISetting $setting */
  70. $setting = \OC::$server->query($settingClass);
  71. $priority = $setting->getPriority();
  72. $this->assertIsInt($setting->getPriority());
  73. $this->assertGreaterThanOrEqual(0, $priority);
  74. $this->assertLessThanOrEqual(100, $priority);
  75. }
  76. /**
  77. * @dataProvider dataSettings
  78. * @param string $settingClass
  79. */
  80. public function testCanChangeStream($settingClass) {
  81. /** @var ISetting $setting */
  82. $setting = \OC::$server->query($settingClass);
  83. $this->assertIsBool($setting->canChangeStream());
  84. }
  85. /**
  86. * @dataProvider dataSettings
  87. * @param string $settingClass
  88. */
  89. public function testIsDefaultEnabledStream($settingClass) {
  90. /** @var ISetting $setting */
  91. $setting = \OC::$server->query($settingClass);
  92. $this->assertIsBool($setting->isDefaultEnabledStream());
  93. }
  94. /**
  95. * @dataProvider dataSettings
  96. * @param string $settingClass
  97. */
  98. public function testCanChangeMail($settingClass) {
  99. /** @var ISetting $setting */
  100. $setting = \OC::$server->query($settingClass);
  101. $this->assertIsBool($setting->canChangeMail());
  102. }
  103. /**
  104. * @dataProvider dataSettings
  105. * @param string $settingClass
  106. */
  107. public function testIsDefaultEnabledMail($settingClass) {
  108. /** @var ISetting $setting */
  109. $setting = \OC::$server->query($settingClass);
  110. $this->assertIsBool($setting->isDefaultEnabledMail());
  111. }
  112. }