aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Updater/ChangesCheckTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Updater/ChangesCheckTest.php')
-rw-r--r--tests/lib/Updater/ChangesCheckTest.php43
1 files changed, 17 insertions, 26 deletions
diff --git a/tests/lib/Updater/ChangesCheckTest.php b/tests/lib/Updater/ChangesCheckTest.php
index 81eaa95d1fe..dd0d97a9e80 100644
--- a/tests/lib/Updater/ChangesCheckTest.php
+++ b/tests/lib/Updater/ChangesCheckTest.php
@@ -42,7 +42,7 @@ class ChangesCheckTest extends TestCase {
$this->checker = new ChangesCheck($this->clientService, $this->mapper, $this->logger);
}
- public function statusCodeProvider():array {
+ public static function statusCodeProvider(): array {
return [
[200, ChangesCheck::RESPONSE_HAS_CONTENT],
[304, ChangesCheck::RESPONSE_USE_CACHE],
@@ -51,9 +51,7 @@ class ChangesCheckTest extends TestCase {
];
}
- /**
- * @dataProvider statusCodeProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('statusCodeProvider')]
public function testEvaluateResponse(int $statusCode, int $expected): void {
$response = $this->createMock(IResponse::class);
$response->expects($this->atLeastOnce())
@@ -74,8 +72,10 @@ class ChangesCheckTest extends TestCase {
$entry = $this->createMock(Changes::class);
$entry->expects($this->exactly(2))
->method('__call')
- ->withConsecutive(['getVersion'], ['setVersion', [$version]])
- ->willReturnOnConsecutiveCalls('', null);
+ ->willReturnMap([
+ ['getVersion', [], ''],
+ ['setVersion', [$version], null],
+ ]);
$this->mapper->expects($this->once())
->method('insert');
@@ -100,7 +100,7 @@ class ChangesCheckTest extends TestCase {
$this->invokePrivate($this->checker, 'cacheResult', [$entry, $version]);
}
- public function changesXMLProvider(): array {
+ public static function changesXMLProvider(): array {
return [
[ # 0 - full example
'<?xml version="1.0" encoding="utf-8" ?>
@@ -269,24 +269,20 @@ class ChangesCheckTest extends TestCase {
];
}
- /**
- * @dataProvider changesXMLProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('changesXMLProvider')]
public function testExtractData(string $body, array $expected): void {
$actual = $this->invokePrivate($this->checker, 'extractData', [$body]);
$this->assertSame($expected, $actual);
}
- public function etagProvider() {
+ public static function etagProvider() {
return [
[''],
['a27aab83d8205d73978435076e53d143']
];
}
- /**
- * @dataProvider etagProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('etagProvider')]
public function testQueryChangesServer(string $etag): void {
$uri = 'https://changes.nextcloud.server/?13.0.5';
$entry = $this->createMock(Changes::class);
@@ -310,7 +306,7 @@ class ChangesCheckTest extends TestCase {
$this->assertInstanceOf(IResponse::class, $response);
}
- public function versionProvider(): array {
+ public static function versionProvider(): array {
return [
['13.0.7', '13.0.7'],
['13.0.7.3', '13.0.7'],
@@ -321,29 +317,24 @@ class ChangesCheckTest extends TestCase {
];
}
- /**
- * @dataProvider versionProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('versionProvider')]
public function testNormalizeVersion(string $input, string $expected): void {
$normalized = $this->checker->normalizeVersion($input);
$this->assertSame($expected, $normalized);
}
- public function changeDataProvider():array {
- $testDataFound = $testDataNotFound = $this->versionProvider();
- array_walk($testDataFound, function (&$params) {
+ public static function changeDataProvider():array {
+ $testDataFound = $testDataNotFound = self::versionProvider();
+ array_walk($testDataFound, static function (&$params): void {
$params[] = true;
});
- array_walk($testDataNotFound, function (&$params) {
+ array_walk($testDataNotFound, static function (&$params): void {
$params[] = false;
});
return array_merge($testDataFound, $testDataNotFound);
}
- /**
- * @dataProvider changeDataProvider
- *
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('changeDataProvider')]
public function testGetChangesForVersion(string $inputVersion, string $normalizedVersion, bool $isFound): void {
$mocker = $this->mapper->expects($this->once())
->method('getChanges')