diff options
Diffstat (limited to 'apps/settings/tests/SetupChecks/SupportedDatabaseTest.php')
-rw-r--r-- | apps/settings/tests/SetupChecks/SupportedDatabaseTest.php | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php b/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php index 35c27769e78..6c75df47aa0 100644 --- a/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php +++ b/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php @@ -3,39 +3,49 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Morris Jobke <hey@morrisjobke.de> - * - * @author Morris Jobke <hey@morrisjobke.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace OCA\Settings\Tests; +namespace OCA\Settings\Tests\SetupChecks; use OCA\Settings\SetupChecks\SupportedDatabase; +use OCP\IDBConnection; use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Server; +use OCP\SetupCheck\SetupResult; use Test\TestCase; /** * @group DB */ class SupportedDatabaseTest extends TestCase { + private IL10N $l10n; + private IUrlGenerator $urlGenerator; + private IDBConnection $connection; + + private SupportedDatabase $check; + + protected function setUp(): void { + parent::setUp(); + + $this->l10n = $this->createMock(IL10N::class); + $this->urlGenerator = $this->createMock(IURLGenerator::class); + $this->connection = Server::get(IDBConnection::class); + + $this->check = new SupportedDatabase( + $this->l10n, + $this->urlGenerator, + Server::get(IDBConnection::class) + ); + } + public function testPass(): void { - $l10n = $this->getMockBuilder(IL10N::class)->getMock(); - $check = new SupportedDatabase($l10n, \OC::$server->getDatabaseConnection()); - $this->assertTrue($check->run()); + if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) { + /** SQlite always gets a warning */ + $this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity()); + } else { + $this->assertContains($this->check->run()->getSeverity(), [SetupResult::SUCCESS, SetupResult::INFO]); + } } } |