diff options
Diffstat (limited to 'tests/lib/UpdaterTest.php')
-rw-r--r-- | tests/lib/UpdaterTest.php | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/tests/lib/UpdaterTest.php b/tests/lib/UpdaterTest.php index 1affd6d020a..37a4a105628 100644 --- a/tests/lib/UpdaterTest.php +++ b/tests/lib/UpdaterTest.php @@ -1,23 +1,9 @@ <?php + /** - * @author Lukas Reschke <lukas@owncloud.com> - * @author Victor Dubiniuk <dubiniuk@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace Test; @@ -25,38 +11,41 @@ namespace Test; use OC\Installer; use OC\IntegrityCheck\Checker; use OC\Updater; +use OCP\IAppConfig; use OCP\IConfig; -use OCP\ILogger; +use OCP\ServerVersion; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; class UpdaterTest extends TestCase { - /** @var IConfig | \PHPUnit\Framework\MockObject\MockObject */ + /** @var ServerVersion|MockObject */ + private $serverVersion; + /** @var IConfig|MockObject */ private $config; - /** @var ILogger | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IAppConfig|MockObject */ + private $appConfig; + /** @var LoggerInterface|MockObject */ private $logger; /** @var Updater */ private $updater; - /** @var Checker | \PHPUnit\Framework\MockObject\MockObject */ + /** @var Checker|MockObject */ private $checker; - /** @var Installer|\PHPUnit\Framework\MockObject\MockObject */ + /** @var Installer|MockObject */ private $installer; protected function setUp(): void { parent::setUp(); - $this->config = $this->getMockBuilder(IConfig::class) - ->disableOriginalConstructor() - ->getMock(); - $this->logger = $this->getMockBuilder(ILogger::class) - ->disableOriginalConstructor() - ->getMock(); - $this->checker = $this->getMockBuilder(Checker::class) - ->disableOriginalConstructor() - ->getMock(); - $this->installer = $this->getMockBuilder(Installer::class) - ->disableOriginalConstructor() - ->getMock(); + $this->serverVersion = $this->createMock(ServerVersion::class); + $this->config = $this->createMock(IConfig::class); + $this->appConfig = $this->createMock(IAppConfig::class); + $this->logger = $this->createMock(LoggerInterface::class); + $this->checker = $this->createMock(Checker::class); + $this->installer = $this->createMock(Installer::class); $this->updater = new Updater( + $this->serverVersion, $this->config, + $this->appConfig, $this->checker, $this->logger, $this->installer @@ -66,7 +55,7 @@ class UpdaterTest extends TestCase { /** * @return array */ - public function versionCompatibilityTestData() { + public static function versionCompatibilityTestData(): array { return [ // Upgrade with invalid version ['9.1.1.13', '11.0.2.25', ['nextcloud' => ['11.0' => true]], false], @@ -93,7 +82,6 @@ class UpdaterTest extends TestCase { } /** - * @dataProvider versionCompatibilityTestData * * @param string $oldVersion * @param string $newVersion @@ -102,9 +90,10 @@ class UpdaterTest extends TestCase { * @param bool $debug * @param string $vendor */ - public function testIsUpgradePossible($oldVersion, $newVersion, $allowedVersions, $result, $debug = false, $vendor = 'nextcloud') { + #[\PHPUnit\Framework\Attributes\DataProvider('versionCompatibilityTestData')] + public function testIsUpgradePossible($oldVersion, $newVersion, $allowedVersions, $result, $debug = false, $vendor = 'nextcloud'): void { $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('debug', false) ->willReturn($debug); $this->config->expects($this->any()) |