aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/SetupTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/SetupTest.php')
-rw-r--r--tests/lib/SetupTest.php56
1 files changed, 26 insertions, 30 deletions
diff --git a/tests/lib/SetupTest.php b/tests/lib/SetupTest.php
index eacc165650c..0be7eab36f6 100644
--- a/tests/lib/SetupTest.php
+++ b/tests/lib/SetupTest.php
@@ -1,9 +1,9 @@
<?php
+
/**
- * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -14,27 +14,20 @@ use OC\Setup;
use OC\SystemConfig;
use OCP\Defaults;
use OCP\IL10N;
+use OCP\L10N\IFactory as IL10NFactory;
use OCP\Security\ISecureRandom;
-use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
class SetupTest extends \Test\TestCase {
- /** @var SystemConfig|MockObject */
- protected $config;
- /** @var \bantu\IniGetWrapper\IniGetWrapper|MockObject */
- private $iniWrapper;
- /** @var \OCP\IL10N|MockObject */
- private $l10n;
- /** @var Defaults|MockObject */
- private $defaults;
- /** @var \OC\Setup|MockObject */
- protected $setupClass;
- /** @var LoggerInterface|MockObject */
- protected $logger;
- /** @var \OCP\Security\ISecureRandom|MockObject */
- protected $random;
- /** @var Installer|MockObject */
- protected $installer;
+ protected SystemConfig $config;
+ private IniGetWrapper $iniWrapper;
+ private IL10N $l10n;
+ private IL10NFactory $l10nFactory;
+ private Defaults $defaults;
+ protected Setup $setupClass;
+ protected LoggerInterface $logger;
+ protected ISecureRandom $random;
+ protected Installer $installer;
protected function setUp(): void {
parent::setUp();
@@ -42,17 +35,20 @@ class SetupTest extends \Test\TestCase {
$this->config = $this->createMock(SystemConfig::class);
$this->iniWrapper = $this->createMock(IniGetWrapper::class);
$this->l10n = $this->createMock(IL10N::class);
+ $this->l10nFactory = $this->createMock(IL10NFactory::class);
+ $this->l10nFactory->method('get')
+ ->willReturn($this->l10n);
$this->defaults = $this->createMock(Defaults::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->random = $this->createMock(ISecureRandom::class);
$this->installer = $this->createMock(Installer::class);
$this->setupClass = $this->getMockBuilder(Setup::class)
- ->setMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo'])
- ->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10n, $this->defaults, $this->logger, $this->random, $this->installer])
+ ->onlyMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo'])
+ ->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10nFactory, $this->defaults, $this->logger, $this->random, $this->installer])
->getMock();
}
- public function testGetSupportedDatabasesWithOneWorking() {
+ public function testGetSupportedDatabasesWithOneWorking(): void {
$this->config
->expects($this->once())
->method('getValue')
@@ -75,7 +71,7 @@ class SetupTest extends \Test\TestCase {
$this->assertSame($expectedResult, $result);
}
- public function testGetSupportedDatabasesWithNoWorking() {
+ public function testGetSupportedDatabasesWithNoWorking(): void {
$this->config
->expects($this->once())
->method('getValue')
@@ -95,7 +91,7 @@ class SetupTest extends \Test\TestCase {
$this->assertSame([], $result);
}
- public function testGetSupportedDatabasesWithAllWorking() {
+ public function testGetSupportedDatabasesWithAllWorking(): void {
$this->config
->expects($this->once())
->method('getValue')
@@ -121,7 +117,7 @@ class SetupTest extends \Test\TestCase {
}
- public function testGetSupportedDatabaseException() {
+ public function testGetSupportedDatabaseException(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Supported databases are not properly configured.');
@@ -133,11 +129,11 @@ class SetupTest extends \Test\TestCase {
}
/**
- * @dataProvider findWebRootProvider
* @param $url
* @param $expected
*/
- public function testFindWebRootCli($url, $expected) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('findWebRootProvider')]
+ public function testFindWebRootCli($url, $expected): void {
$cliState = \OC::$CLI;
$this->config
@@ -156,7 +152,7 @@ class SetupTest extends \Test\TestCase {
$this->assertSame($webRoot, $expected);
}
- public function findWebRootProvider(): array {
+ public static function findWebRootProvider(): array {
return [
'https://www.example.com/nextcloud/' => ['https://www.example.com/nextcloud/', '/nextcloud'],
'https://www.example.com/nextcloud' => ['https://www.example.com/nextcloud', '/nextcloud'],