GenericTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\DAV\Tests\unit\CalDAV\Activity\Setting;
  7. use OCA\DAV\CalDAV\Activity\Setting\Calendar;
  8. use OCA\DAV\CalDAV\Activity\Setting\Event;
  9. use OCA\DAV\CalDAV\Activity\Setting\Todo;
  10. use OCP\Activity\ISetting;
  11. use Test\TestCase;
  12. class GenericTest extends TestCase {
  13. public function dataSettings() {
  14. return [
  15. [Calendar::class],
  16. [Event::class],
  17. [Todo::class],
  18. ];
  19. }
  20. /**
  21. * @dataProvider dataSettings
  22. * @param string $settingClass
  23. */
  24. public function testImplementsInterface($settingClass): void {
  25. $setting = \OC::$server->query($settingClass);
  26. $this->assertInstanceOf(ISetting::class, $setting);
  27. }
  28. /**
  29. * @dataProvider dataSettings
  30. * @param string $settingClass
  31. */
  32. public function testGetIdentifier($settingClass): void {
  33. /** @var ISetting $setting */
  34. $setting = \OC::$server->query($settingClass);
  35. $this->assertIsString($setting->getIdentifier());
  36. }
  37. /**
  38. * @dataProvider dataSettings
  39. * @param string $settingClass
  40. */
  41. public function testGetName($settingClass): void {
  42. /** @var ISetting $setting */
  43. $setting = \OC::$server->query($settingClass);
  44. $this->assertIsString($setting->getName());
  45. }
  46. /**
  47. * @dataProvider dataSettings
  48. * @param string $settingClass
  49. */
  50. public function testGetPriority($settingClass): void {
  51. /** @var ISetting $setting */
  52. $setting = \OC::$server->query($settingClass);
  53. $priority = $setting->getPriority();
  54. $this->assertIsInt($setting->getPriority());
  55. $this->assertGreaterThanOrEqual(0, $priority);
  56. $this->assertLessThanOrEqual(100, $priority);
  57. }
  58. /**
  59. * @dataProvider dataSettings
  60. * @param string $settingClass
  61. */
  62. public function testCanChangeStream($settingClass): void {
  63. /** @var ISetting $setting */
  64. $setting = \OC::$server->query($settingClass);
  65. $this->assertIsBool($setting->canChangeStream());
  66. }
  67. /**
  68. * @dataProvider dataSettings
  69. * @param string $settingClass
  70. */
  71. public function testIsDefaultEnabledStream($settingClass): void {
  72. /** @var ISetting $setting */
  73. $setting = \OC::$server->query($settingClass);
  74. $this->assertIsBool($setting->isDefaultEnabledStream());
  75. }
  76. /**
  77. * @dataProvider dataSettings
  78. * @param string $settingClass
  79. */
  80. public function testCanChangeMail($settingClass): void {
  81. /** @var ISetting $setting */
  82. $setting = \OC::$server->query($settingClass);
  83. $this->assertIsBool($setting->canChangeMail());
  84. }
  85. /**
  86. * @dataProvider dataSettings
  87. * @param string $settingClass
  88. */
  89. public function testIsDefaultEnabledMail($settingClass): void {
  90. /** @var ISetting $setting */
  91. $setting = \OC::$server->query($settingClass);
  92. $this->assertIsBool($setting->isDefaultEnabledMail());
  93. }
  94. }