SupportedDatabaseTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\SetupCheck\SetupResult;
  13. use Test\TestCase;
  14. /**
  15. * @group DB
  16. */
  17. class SupportedDatabaseTest extends TestCase {
  18. private IL10N $l10n;
  19. private IUrlGenerator $urlGenerator;
  20. private IDBConnection $connection;
  21. private SupportedDatabase $check;
  22. protected function setUp(): void {
  23. parent::setUp();
  24. $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
  25. $this->urlGenerator = $this->getMockBuilder(IUrlGenerator::class)->getMock();
  26. $this->connection = \OCP\Server::get(IDBConnection::class);
  27. $this->check = new SupportedDatabase(
  28. $this->l10n,
  29. $this->urlGenerator,
  30. \OCP\Server::get(IDBConnection::class)
  31. );
  32. }
  33. public function testPass(): void {
  34. if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) {
  35. /** SQlite always gets a warning */
  36. $this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity());
  37. } else {
  38. $this->assertContains($this->check->run()->getSeverity(), [SetupResult::SUCCESS, SetupResult::INFO]);
  39. }
  40. }
  41. }