ServicesTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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\Theming\Tests;
  7. use OCA\Theming\Capabilities;
  8. use OCA\Theming\Controller\ThemingController;
  9. use OCA\Theming\Settings\Admin;
  10. use OCA\Theming\Settings\PersonalSection;
  11. use OCA\Theming\ThemingDefaults;
  12. use OCA\Theming\Util;
  13. use OCP\AppFramework\App;
  14. use OCP\AppFramework\IAppContainer;
  15. use OCP\Capabilities\ICapability;
  16. use OCP\IL10N;
  17. use OCP\Settings\IIconSection;
  18. use OCP\Settings\ISettings;
  19. use Test\TestCase;
  20. /**
  21. * Class ServicesTest
  22. *
  23. * @group DB
  24. * @package OCA\Theming\Tests
  25. */
  26. class ServicesTest extends TestCase {
  27. /** @var \OCA\Activity\AppInfo\Application */
  28. protected $app;
  29. /** @var IAppContainer */
  30. protected $container;
  31. protected function setUp(): void {
  32. parent::setUp();
  33. $this->app = new App('theming');
  34. $this->container = $this->app->getContainer();
  35. }
  36. public function queryData() {
  37. return [
  38. [IL10N::class],
  39. // lib/
  40. [Capabilities::class],
  41. [Capabilities::class, ICapability::class],
  42. [ThemingDefaults::class],
  43. [ThemingDefaults::class, \OC_Defaults::class],
  44. [Util::class],
  45. // Controller
  46. [ThemingController::class, ThemingController::class],
  47. // Settings
  48. [Admin::class],
  49. [Admin::class, ISettings::class],
  50. [PersonalSection::class],
  51. [PersonalSection::class, IIconSection::class],
  52. ];
  53. }
  54. /**
  55. * @dataProvider queryData
  56. * @param string $service
  57. * @param string $expected
  58. */
  59. public function testContainerQuery($service, $expected = null): void {
  60. if ($expected === null) {
  61. $expected = $service;
  62. }
  63. $this->assertTrue($this->container->query($service) instanceof $expected);
  64. }
  65. }