diff options
Diffstat (limited to 'tests/Core/Command/Config')
9 files changed, 27 insertions, 38 deletions
diff --git a/tests/Core/Command/Config/App/DeleteConfigTest.php b/tests/Core/Command/Config/App/DeleteConfigTest.php index 6f7bfbf3a7c..9e43f389214 100644 --- a/tests/Core/Command/Config/App/DeleteConfigTest.php +++ b/tests/Core/Command/Config/App/DeleteConfigTest.php @@ -70,9 +70,7 @@ class DeleteConfigTest extends TestCase { ]; } - /** - * @dataProvider dataDelete - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataDelete')] public function testDelete(string $configName, bool $configExists, bool $checkIfExists, int $expectedReturn, string $expectedMessage): void { $this->appConfig->expects(($checkIfExists) ? $this->once() : $this->never()) ->method('getKeys') diff --git a/tests/Core/Command/Config/App/GetConfigTest.php b/tests/Core/Command/Config/App/GetConfigTest.php index 63a02f263d0..13392cddf55 100644 --- a/tests/Core/Command/Config/App/GetConfigTest.php +++ b/tests/Core/Command/Config/App/GetConfigTest.php @@ -80,9 +80,7 @@ class GetConfigTest extends TestCase { ]; } - /** - * @dataProvider dataGet - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGet')] public function testGet(string $configName, mixed $value, bool $configExists, mixed $defaultValue, bool $hasDefault, string $outputFormat, int $expectedReturn, ?string $expectedMessage): void { if (!$expectedReturn) { if ($configExists) { diff --git a/tests/Core/Command/Config/App/SetConfigTest.php b/tests/Core/Command/Config/App/SetConfigTest.php index 596439d85a8..a5c62368163 100644 --- a/tests/Core/Command/Config/App/SetConfigTest.php +++ b/tests/Core/Command/Config/App/SetConfigTest.php @@ -60,9 +60,7 @@ class SetConfigTest extends TestCase { ]; } - /** - * @dataProvider dataSet - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSet')] public function testSet(string $configName, mixed $newValue, bool $configExists, bool $updateOnly, bool $updated, string $expectedMessage): void { $this->appConfig->method('hasKey') ->with('app-name', $configName) diff --git a/tests/Core/Command/Config/ImportTest.php b/tests/Core/Command/Config/ImportTest.php index 3cce8cb0243..14cdd714d12 100644 --- a/tests/Core/Command/Config/ImportTest.php +++ b/tests/Core/Command/Config/ImportTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -34,7 +35,7 @@ class ImportTest extends TestCase { $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); - /** @var \OCP\IConfig $config */ + /** @var IConfig $config */ $this->command = new Import($config); } @@ -49,10 +50,9 @@ class ImportTest extends TestCase { } /** - * @dataProvider validateAppsArrayData - * * @param mixed $configValue */ + #[\PHPUnit\Framework\Attributes\DataProvider('validateAppsArrayData')] public function testValidateAppsArray($configValue): void { $this->invokePrivate($this->command, 'validateAppsArray', [['app' => ['name' => $configValue]]]); $this->assertTrue(true, 'Asserting that no exception is thrown'); @@ -68,10 +68,9 @@ class ImportTest extends TestCase { } /** - * @dataProvider validateAppsArrayThrowsData - * * @param mixed $configValue */ + #[\PHPUnit\Framework\Attributes\DataProvider('validateAppsArrayThrowsData')] public function testValidateAppsArrayThrows($configValue): void { try { $this->invokePrivate($this->command, 'validateAppsArray', [['app' => ['name' => $configValue]]]); @@ -98,10 +97,9 @@ class ImportTest extends TestCase { } /** - * @dataProvider checkTypeRecursivelyData - * * @param mixed $configValue */ + #[\PHPUnit\Framework\Attributes\DataProvider('checkTypeRecursivelyData')] public function testCheckTypeRecursively($configValue): void { $this->invokePrivate($this->command, 'checkTypeRecursively', [$configValue, 'name']); $this->assertTrue(true, 'Asserting that no exception is thrown'); @@ -117,10 +115,9 @@ class ImportTest extends TestCase { } /** - * @dataProvider checkTypeRecursivelyThrowsData - * * @param mixed $configValue */ + #[\PHPUnit\Framework\Attributes\DataProvider('checkTypeRecursivelyThrowsData')] public function testCheckTypeRecursivelyThrows($configValue): void { try { $this->invokePrivate($this->command, 'checkTypeRecursively', [$configValue, 'name']); @@ -139,10 +136,9 @@ class ImportTest extends TestCase { } /** - * @dataProvider validateArrayData - * * @param array $configArray */ + #[\PHPUnit\Framework\Attributes\DataProvider('validateArrayData')] public function testValidateArray($configArray): void { $this->invokePrivate($this->command, 'validateArray', [$configArray]); $this->assertTrue(true, 'Asserting that no exception is thrown'); @@ -157,11 +153,11 @@ class ImportTest extends TestCase { } /** - * @dataProvider validateArrayThrowsData * * @param mixed $configArray * @param string $expectedException */ + #[\PHPUnit\Framework\Attributes\DataProvider('validateArrayThrowsData')] public function testValidateArrayThrows($configArray, $expectedException): void { try { $this->invokePrivate($this->command, 'validateArray', [$configArray]); diff --git a/tests/Core/Command/Config/ListConfigsTest.php b/tests/Core/Command/Config/ListConfigsTest.php index 216a6133579..2f2de288e9d 100644 --- a/tests/Core/Command/Config/ListConfigsTest.php +++ b/tests/Core/Command/Config/ListConfigsTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -261,7 +262,6 @@ class ListConfigsTest extends TestCase { } /** - * @dataProvider listData * * @param string $app * @param array $systemConfigs @@ -270,6 +270,7 @@ class ListConfigsTest extends TestCase { * @param bool $private * @param string $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('listData')] public function testList($app, $systemConfigs, $systemConfigMap, $appConfig, $private, $expected): void { $this->systemConfig->expects($this->any()) ->method('getKeys') diff --git a/tests/Core/Command/Config/System/CastHelperTest.php b/tests/Core/Command/Config/System/CastHelperTest.php index 0d3ca032026..924887daaf7 100644 --- a/tests/Core/Command/Config/System/CastHelperTest.php +++ b/tests/Core/Command/Config/System/CastHelperTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-only @@ -36,9 +37,7 @@ class CastHelperTest extends TestCase { ]; } - /** - * @dataProvider castValueProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('castValueProvider')] public function testCastValue($value, $type, $expectedValue): void { $this->assertSame( $expectedValue, @@ -58,9 +57,7 @@ class CastHelperTest extends TestCase { ]; } - /** - * @dataProvider castValueInvalidProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('castValueInvalidProvider')] public function testCastValueInvalid($value, $type): void { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Core/Command/Config/System/DeleteConfigTest.php b/tests/Core/Command/Config/System/DeleteConfigTest.php index 31e238573d0..b0a3580e1cd 100644 --- a/tests/Core/Command/Config/System/DeleteConfigTest.php +++ b/tests/Core/Command/Config/System/DeleteConfigTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -34,7 +35,7 @@ class DeleteConfigTest extends TestCase { $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); - /** @var \OC\SystemConfig $systemConfig */ + /** @var SystemConfig $systemConfig */ $this->command = new DeleteConfig($systemConfig); } @@ -72,7 +73,6 @@ class DeleteConfigTest extends TestCase { } /** - * @dataProvider deleteData * * @param string $configName * @param bool $configExists @@ -80,6 +80,7 @@ class DeleteConfigTest extends TestCase { * @param int $expectedReturn * @param string $expectedMessage */ + #[\PHPUnit\Framework\Attributes\DataProvider('deleteData')] public function testDelete($configName, $configExists, $checkIfExists, $expectedReturn, $expectedMessage): void { $this->systemConfig->expects(($checkIfExists) ? $this->once() : $this->never()) ->method('getKeys') @@ -165,7 +166,6 @@ class DeleteConfigTest extends TestCase { } /** - * @dataProvider deleteArrayData * * @param string[] $configNames * @param bool $configKeyExists @@ -175,6 +175,7 @@ class DeleteConfigTest extends TestCase { * @param int $expectedReturn * @param string $expectedMessage */ + #[\PHPUnit\Framework\Attributes\DataProvider('deleteArrayData')] public function testArrayDelete(array $configNames, $configKeyExists, $checkIfKeyExists, $configValue, $updateValue, $expectedReturn, $expectedMessage): void { $this->systemConfig->expects(($checkIfKeyExists) ? $this->once() : $this->never()) ->method('getKeys') diff --git a/tests/Core/Command/Config/System/GetConfigTest.php b/tests/Core/Command/Config/System/GetConfigTest.php index daaee5605b7..8b84fd14198 100644 --- a/tests/Core/Command/Config/System/GetConfigTest.php +++ b/tests/Core/Command/Config/System/GetConfigTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -34,7 +35,7 @@ class GetConfigTest extends TestCase { $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); - /** @var \OC\SystemConfig $systemConfig */ + /** @var SystemConfig $systemConfig */ $this->command = new GetConfig($systemConfig); } @@ -88,7 +89,6 @@ class GetConfigTest extends TestCase { } /** - * @dataProvider getData * * @param string[] $configNames * @param mixed $value @@ -99,6 +99,7 @@ class GetConfigTest extends TestCase { * @param int $expectedReturn * @param string $expectedMessage */ + #[\PHPUnit\Framework\Attributes\DataProvider('getData')] public function testGet($configNames, $value, $configExists, $defaultValue, $hasDefault, $outputFormat, $expectedReturn, $expectedMessage): void { if (is_array($configNames)) { $configName = $configNames[0]; diff --git a/tests/Core/Command/Config/System/SetConfigTest.php b/tests/Core/Command/Config/System/SetConfigTest.php index 73fee8bee5f..a99b832c160 100644 --- a/tests/Core/Command/Config/System/SetConfigTest.php +++ b/tests/Core/Command/Config/System/SetConfigTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -35,7 +36,7 @@ class SetConfigTest extends TestCase { $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); - /** @var \OC\SystemConfig $systemConfig */ + /** @var SystemConfig $systemConfig */ $this->command = new SetConfig($systemConfig, new CastHelper()); } @@ -49,13 +50,13 @@ class SetConfigTest extends TestCase { } /** - * @dataProvider dataTest * * @param array $configNames * @param string $newValue * @param mixed $existingData * @param mixed $expectedValue */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTest')] public function testSet($configNames, $newValue, $existingData, $expectedValue): void { $this->systemConfig->expects($this->once()) ->method('setValue') @@ -86,9 +87,7 @@ class SetConfigTest extends TestCase { ]; } - /** - * @dataProvider setUpdateOnlyProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setUpdateOnlyProvider')] public function testSetUpdateOnly($configNames, $existingData): void { $this->expectException(\UnexpectedValueException::class); |