Skip to content

Commit de70dcf

Browse files
authored
Merge pull request #21981 from nextcloud/backport/21972/stable19
[stable19] Fix PHPUnit deprecation warnings
2 parents d7fa01b + 72fc3ec commit de70dcf

File tree

16 files changed

+43
-80
lines changed

16 files changed

+43
-80
lines changed

apps/dav/tests/unit/CalDAV/CalDavBackendTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function testCalendarObjectsOperations() {
279279
$this->assertCount(0, $calendarObjects);
280280
}
281281

282-
282+
283283
public function testMultipleCalendarObjectsWithSameUID() {
284284
$this->expectException(\Sabre\DAV\Exception\BadRequest::class);
285285
$this->expectExceptionMessage('Calendar object with uid already exists in this calendar collection.');
@@ -441,7 +441,7 @@ public function testCalendarQuery($expectedEventsInResult, $propFilters, $compFi
441441
$expectedEventsInResult = array_map(function ($index) use ($events) {
442442
return $events[$index];
443443
}, $expectedEventsInResult);
444-
$this->assertEquals($expectedEventsInResult, $result, '', 0.0, 10, true);
444+
$this->assertEqualsCanonicalizing($expectedEventsInResult, $result);
445445
}
446446

447447
public function testGetCalendarObjectByUID() {

apps/dav/tests/unit/Command/ListCalendarsTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ protected function setUp(): void {
6363
);
6464
}
6565

66-
6766
public function testWithBadUser() {
6867
$this->expectException(\InvalidArgumentException::class);
6968

@@ -76,7 +75,7 @@ public function testWithBadUser() {
7675
$commandTester->execute([
7776
'uid' => self::USERNAME,
7877
]);
79-
$this->assertContains("User <" . self::USERNAME . "> in unknown", $commandTester->getDisplay());
78+
$this->assertStringContainsString("User <" . self::USERNAME . "> in unknown", $commandTester->getDisplay());
8079
}
8180

8281
public function testWithCorrectUserWithNoCalendars() {
@@ -94,7 +93,7 @@ public function testWithCorrectUserWithNoCalendars() {
9493
$commandTester->execute([
9594
'uid' => self::USERNAME,
9695
]);
97-
$this->assertContains("User <" . self::USERNAME . "> has no calendars\n", $commandTester->getDisplay());
96+
$this->assertStringContainsString("User <" . self::USERNAME . "> has no calendars\n", $commandTester->getDisplay());
9897
}
9998

10099
public function dataExecute() {
@@ -133,7 +132,7 @@ public function testWithCorrectUser(bool $readOnly, string $output) {
133132
$commandTester->execute([
134133
'uid' => self::USERNAME,
135134
]);
136-
$this->assertContains($output, $commandTester->getDisplay());
137-
$this->assertNotContains(BirthdayService::BIRTHDAY_CALENDAR_URI, $commandTester->getDisplay());
135+
$this->assertStringContainsString($output, $commandTester->getDisplay());
136+
$this->assertStringNotContainsString(BirthdayService::BIRTHDAY_CALENDAR_URI, $commandTester->getDisplay());
138137
}
139138
}

apps/dav/tests/unit/Command/MoveCalendarTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function testWithBadUserOrigin($userOriginExists, $userDestinationExists)
121121
]);
122122
}
123123

124-
124+
125125
public function testMoveWithInexistantCalendar() {
126126
$this->expectException(\InvalidArgumentException::class);
127127
$this->expectExceptionMessage('User <user> has no calendar named <personal>. You can run occ dav:list-calendars to list calendars URIs for this user.');
@@ -148,7 +148,7 @@ public function testMoveWithInexistantCalendar() {
148148
]);
149149
}
150150

151-
151+
152152
public function testMoveWithExistingDestinationCalendar() {
153153
$this->expectException(\InvalidArgumentException::class);
154154
$this->expectExceptionMessage('User <user2> already has a calendar named <personal>.');
@@ -313,7 +313,7 @@ public function testMoveWithDestinationPartOfGroup() {
313313
'destinationuid' => 'user2',
314314
]);
315315

316-
$this->assertContains("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
316+
$this->assertStringContainsString("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
317317
}
318318

319319
public function testMoveWithDestinationNotPartOfGroupAndForce() {
@@ -360,7 +360,7 @@ public function testMoveWithDestinationNotPartOfGroupAndForce() {
360360
'--force' => true
361361
]);
362362

363-
$this->assertContains("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
363+
$this->assertStringContainsString("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
364364
}
365365

366366
public function dataTestMoveWithCalendarAlreadySharedToDestination(): array {

apps/federatedfilesharing/tests/FederatedShareProviderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ public function testCreate() {
197197
'accepted' => 0,
198198
'token' => 'token',
199199
];
200-
$this->assertArraySubset($expected, $data);
200+
foreach (array_keys($expected) as $key) {
201+
$this->assertEquals($expected[$key], $data[$key], "Assert that value for key '$key' is the same");
202+
}
201203

202204
$this->assertEquals($data['id'], $share->getId());
203205
$this->assertEquals(\OCP\Share::SHARE_TYPE_REMOTE, $share->getShareType());

tests/Core/Command/TwoFactorAuth/CleanupTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ public function testCleanup() {
6060

6161
$this->assertEquals(0, $rc);
6262
$output = $this->cmd->getDisplay();
63-
$this->assertContains("All user-provider associations for provider u2f have been removed", $output);
63+
$this->assertStringContainsString("All user-provider associations for provider u2f have been removed", $output);
6464
}
6565
}

tests/Core/Command/TwoFactorAuth/DisableTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testInvalidUID() {
6767
]);
6868

6969
$this->assertEquals(1, $rc);
70-
$this->assertContains("Invalid UID", $this->command->getDisplay());
70+
$this->assertStringContainsString("Invalid UID", $this->command->getDisplay());
7171
}
7272

7373
public function testEnableNotSupported() {
@@ -87,7 +87,7 @@ public function testEnableNotSupported() {
8787
]);
8888

8989
$this->assertEquals(2, $rc);
90-
$this->assertContains("The provider does not support this operation", $this->command->getDisplay());
90+
$this->assertStringContainsString("The provider does not support this operation", $this->command->getDisplay());
9191
}
9292

9393
public function testEnabled() {
@@ -107,6 +107,6 @@ public function testEnabled() {
107107
]);
108108

109109
$this->assertEquals(0, $rc);
110-
$this->assertContains("Two-factor provider totp disabled for user ricky", $this->command->getDisplay());
110+
$this->assertStringContainsString("Two-factor provider totp disabled for user ricky", $this->command->getDisplay());
111111
}
112112
}

tests/Core/Command/TwoFactorAuth/EnableTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testInvalidUID() {
6767
]);
6868

6969
$this->assertEquals(1, $rc);
70-
$this->assertContains("Invalid UID", $this->command->getDisplay());
70+
$this->assertStringContainsString("Invalid UID", $this->command->getDisplay());
7171
}
7272

7373
public function testEnableNotSupported() {
@@ -87,7 +87,7 @@ public function testEnableNotSupported() {
8787
]);
8888

8989
$this->assertEquals(2, $rc);
90-
$this->assertContains("The provider does not support this operation", $this->command->getDisplay());
90+
$this->assertStringContainsString("The provider does not support this operation", $this->command->getDisplay());
9191
}
9292

9393
public function testEnabled() {
@@ -107,6 +107,6 @@ public function testEnabled() {
107107
]);
108108

109109
$this->assertEquals(0, $rc);
110-
$this->assertContains("Two-factor provider totp enabled for user belle", $this->command->getDisplay());
110+
$this->assertStringContainsString("Two-factor provider totp enabled for user belle", $this->command->getDisplay());
111111
}
112112
}

tests/Core/Command/TwoFactorAuth/EnforceTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testEnforce() {
6464

6565
$this->assertEquals(0, $rc);
6666
$display = $this->command->getDisplay();
67-
$this->assertContains("Two-factor authentication is enforced for all users", $display);
67+
$this->assertStringContainsString("Two-factor authentication is enforced for all users", $display);
6868
}
6969

7070
public function testEnforceForOneGroup() {
@@ -82,7 +82,7 @@ public function testEnforceForOneGroup() {
8282

8383
$this->assertEquals(0, $rc);
8484
$display = $this->command->getDisplay();
85-
$this->assertContains("Two-factor authentication is enforced for members of the group(s) twofactorers", $display);
85+
$this->assertStringContainsString("Two-factor authentication is enforced for members of the group(s) twofactorers", $display);
8686
}
8787

8888
public function testEnforceForAllExceptOneGroup() {
@@ -100,7 +100,7 @@ public function testEnforceForAllExceptOneGroup() {
100100

101101
$this->assertEquals(0, $rc);
102102
$display = $this->command->getDisplay();
103-
$this->assertContains("Two-factor authentication is enforced for all users, except members of yoloers", $display);
103+
$this->assertStringContainsString("Two-factor authentication is enforced for all users, except members of yoloers", $display);
104104
}
105105

106106
public function testDisableEnforced() {
@@ -117,7 +117,7 @@ public function testDisableEnforced() {
117117

118118
$this->assertEquals(0, $rc);
119119
$display = $this->command->getDisplay();
120-
$this->assertContains("Two-factor authentication is not enforced", $display);
120+
$this->assertStringContainsString("Two-factor authentication is not enforced", $display);
121121
}
122122

123123
public function testCurrentStateEnabled() {
@@ -129,7 +129,7 @@ public function testCurrentStateEnabled() {
129129

130130
$this->assertEquals(0, $rc);
131131
$display = $this->command->getDisplay();
132-
$this->assertContains("Two-factor authentication is enforced for all users", $display);
132+
$this->assertStringContainsString("Two-factor authentication is enforced for all users", $display);
133133
}
134134

135135
public function testCurrentStateDisabled() {
@@ -141,6 +141,6 @@ public function testCurrentStateDisabled() {
141141

142142
$this->assertEquals(0, $rc);
143143
$display = $this->command->getDisplay();
144-
$this->assertContains("Two-factor authentication is not enforced", $display);
144+
$this->assertStringContainsString("Two-factor authentication is not enforced", $display);
145145
}
146146
}

tests/Core/Command/TwoFactorAuth/StateTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testWrongUID() {
6161
]);
6262

6363
$output = $this->cmd->getDisplay();
64-
$this->assertContains("Invalid UID", $output);
64+
$this->assertStringContainsString("Invalid UID", $output);
6565
}
6666

6767
public function testStateNoProvidersActive() {
@@ -84,7 +84,7 @@ public function testStateNoProvidersActive() {
8484
]);
8585

8686
$output = $this->cmd->getDisplay();
87-
$this->assertContains("Two-factor authentication is not enabled for user eldora", $output);
87+
$this->assertStringContainsString("Two-factor authentication is not enabled for user eldora", $output);
8888
}
8989

9090
public function testStateOneProviderActive() {
@@ -107,6 +107,6 @@ public function testStateOneProviderActive() {
107107
]);
108108

109109
$output = $this->cmd->getDisplay();
110-
$this->assertContains("Two-factor authentication is enabled for user mohamed", $output);
110+
$this->assertStringContainsString("Two-factor authentication is enabled for user mohamed", $output);
111111
}
112112
}

tests/lib/AppFramework/Http/DownloadResponseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected function setUp(): void {
4545
public function testHeaders() {
4646
$headers = $this->response->getHeaders();
4747

48-
$this->assertContains('attachment; filename="file"', $headers['Content-Disposition']);
49-
$this->assertContains('content', $headers['Content-Type']);
48+
$this->assertStringContainsString('attachment; filename="file"', $headers['Content-Disposition']);
49+
$this->assertStringContainsString('content', $headers['Content-Type']);
5050
}
5151
}

0 commit comments

Comments
 (0)