ApplicationTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Joas Schilling <coding@schilljs.com>
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Joas Schilling <coding@schilljs.com>
  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\Settings\Tests\AppInfo;
  26. use OCA\Settings\AppInfo\Application;
  27. use OCA\Settings\Controller\AdminSettingsController;
  28. use OCA\Settings\Controller\AppSettingsController;
  29. use OCA\Settings\Controller\AuthSettingsController;
  30. use OCA\Settings\Controller\CheckSetupController;
  31. use OCA\Settings\Controller\LogSettingsController;
  32. use OCA\Settings\Controller\MailSettingsController;
  33. use OCA\Settings\Controller\UsersController;
  34. use OCA\Settings\Middleware\SubadminMiddleware;
  35. use OCP\AppFramework\Controller;
  36. use OCP\AppFramework\IAppContainer;
  37. use OCP\AppFramework\Middleware;
  38. use Test\TestCase;
  39. /**
  40. * Class ApplicationTest
  41. *
  42. * @package Tests\Settings
  43. * @group DB
  44. */
  45. class ApplicationTest extends TestCase {
  46. /** @var Application */
  47. protected $app;
  48. /** @var IAppContainer */
  49. protected $container;
  50. protected function setUp(): void {
  51. parent::setUp();
  52. $this->app = new Application();
  53. $this->container = $this->app->getContainer();
  54. }
  55. public function testContainerAppName() {
  56. $this->app = new Application();
  57. $this->assertEquals('settings', $this->container->getAppName());
  58. }
  59. public function dataContainerQuery() {
  60. return [
  61. [AdminSettingsController::class, Controller::class],
  62. [AppSettingsController::class, Controller::class],
  63. [AuthSettingsController::class, Controller::class],
  64. [CheckSetupController::class, Controller::class],
  65. [LogSettingsController::class, Controller::class],
  66. [MailSettingsController::class, Controller::class],
  67. [UsersController::class, Controller::class],
  68. [SubadminMiddleware::class, Middleware::class],
  69. ];
  70. }
  71. /**
  72. * @dataProvider dataContainerQuery
  73. * @param string $service
  74. * @param string $expected
  75. */
  76. public function testContainerQuery($service, $expected) {
  77. $this->assertTrue($this->container->query($service) instanceof $expected);
  78. }
  79. }