GenericTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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\Files\Tests\Activity\Setting;
  7. use OCA\Files\Activity\Settings\FavoriteAction;
  8. use OCA\Files\Activity\Settings\FileChanged;
  9. use OCP\Activity\ISetting;
  10. use Test\TestCase;
  11. class GenericTest extends TestCase {
  12. public function dataSettings() {
  13. return [
  14. [FavoriteAction::class],
  15. [FileChanged::class],
  16. [FileChanged::class],
  17. ];
  18. }
  19. /**
  20. * @dataProvider dataSettings
  21. * @param string $settingClass
  22. */
  23. public function testImplementsInterface($settingClass) {
  24. $setting = \OC::$server->query($settingClass);
  25. $this->assertInstanceOf(ISetting::class, $setting);
  26. }
  27. /**
  28. * @dataProvider dataSettings
  29. * @param string $settingClass
  30. */
  31. public function testGetIdentifier($settingClass) {
  32. /** @var ISetting $setting */
  33. $setting = \OC::$server->query($settingClass);
  34. $this->assertIsString($setting->getIdentifier());
  35. }
  36. /**
  37. * @dataProvider dataSettings
  38. * @param string $settingClass
  39. */
  40. public function testGetName($settingClass) {
  41. /** @var ISetting $setting */
  42. $setting = \OC::$server->query($settingClass);
  43. $this->assertIsString($setting->getName());
  44. }
  45. /**
  46. * @dataProvider dataSettings
  47. * @param string $settingClass
  48. */
  49. public function testGetPriority($settingClass) {
  50. /** @var ISetting $setting */
  51. $setting = \OC::$server->query($settingClass);
  52. $priority = $setting->getPriority();
  53. $this->assertIsInt($setting->getPriority());
  54. $this->assertGreaterThanOrEqual(0, $priority);
  55. $this->assertLessThanOrEqual(100, $priority);
  56. }
  57. /**
  58. * @dataProvider dataSettings
  59. * @param string $settingClass
  60. */
  61. public function testCanChangeStream($settingClass) {
  62. /** @var ISetting $setting */
  63. $setting = \OC::$server->query($settingClass);
  64. $this->assertIsBool($setting->canChangeStream());
  65. }
  66. /**
  67. * @dataProvider dataSettings
  68. * @param string $settingClass
  69. */
  70. public function testIsDefaultEnabledStream($settingClass) {
  71. /** @var ISetting $setting */
  72. $setting = \OC::$server->query($settingClass);
  73. $this->assertIsBool($setting->isDefaultEnabledStream());
  74. }
  75. /**
  76. * @dataProvider dataSettings
  77. * @param string $settingClass
  78. */
  79. public function testCanChangeMail($settingClass) {
  80. /** @var ISetting $setting */
  81. $setting = \OC::$server->query($settingClass);
  82. $this->assertIsBool($setting->canChangeMail());
  83. }
  84. /**
  85. * @dataProvider dataSettings
  86. * @param string $settingClass
  87. */
  88. public function testIsDefaultEnabledMail($settingClass) {
  89. /** @var ISetting $setting */
  90. $setting = \OC::$server->query($settingClass);
  91. $this->assertIsBool($setting->isDefaultEnabledMail());
  92. }
  93. }