SupportedDatabaseTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\Tests;
  8. use OCA\Settings\SetupChecks\SupportedDatabase;
  9. use OCP\IDBConnection;
  10. use OCP\IL10N;
  11. use OCP\IUrlGenerator;
  12. use OCP\Server;
  13. use OCP\SetupCheck\SetupResult;
  14. use Test\TestCase;
  15. /**
  16. * @group DB
  17. */
  18. class SupportedDatabaseTest extends TestCase {
  19. private IL10N $l10n;
  20. private IUrlGenerator $urlGenerator;
  21. private IDBConnection $connection;
  22. private SupportedDatabase $check;
  23. protected function setUp(): void {
  24. parent::setUp();
  25. $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
  26. $this->urlGenerator = $this->getMockBuilder(IUrlGenerator::class)->getMock();
  27. $this->connection = Server::get(IDBConnection::class);
  28. $this->check = new SupportedDatabase(
  29. $this->l10n,
  30. $this->urlGenerator,
  31. Server::get(IDBConnection::class)
  32. );
  33. }
  34. public function testPass(): void {
  35. if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) {
  36. /** SQlite always gets a warning */
  37. $this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity());
  38. } else {
  39. $this->assertContains($this->check->run()->getSeverity(), [SetupResult::SUCCESS, SetupResult::INFO]);
  40. }
  41. }
  42. }