GenericTest.php 3.5 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 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\DAV\Tests\unit\CalDAV\Activity\Setting;
  25. use OCA\DAV\CalDAV\Activity\Setting\Calendar;
  26. use OCA\DAV\CalDAV\Activity\Setting\Event;
  27. use OCA\DAV\CalDAV\Activity\Setting\Todo;
  28. use OCP\Activity\ISetting;
  29. use Test\TestCase;
  30. class GenericTest extends TestCase {
  31. public function dataSettings() {
  32. return [
  33. [Calendar::class],
  34. [Event::class],
  35. [Todo::class],
  36. ];
  37. }
  38. /**
  39. * @dataProvider dataSettings
  40. * @param string $settingClass
  41. */
  42. public function testImplementsInterface($settingClass): void {
  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): void {
  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): void {
  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): void {
  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): void {
  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): void {
  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): void {
  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): void {
  108. /** @var ISetting $setting */
  109. $setting = \OC::$server->query($settingClass);
  110. $this->assertIsBool($setting->isDefaultEnabledMail());
  111. }
  112. }