Use assertStringContainsString instead of assertContains on strings

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2020-07-23 13:36:32 +02:00 committed by backportbot[bot]
parent 4570534fed
commit 1d290e15e8
8 changed files with 26 additions and 27 deletions

View File

@ -63,7 +63,6 @@ class ListCalendarsTest extends TestCase {
);
}
public function testWithBadUser() {
$this->expectException(\InvalidArgumentException::class);
@ -76,7 +75,7 @@ class ListCalendarsTest extends TestCase {
$commandTester->execute([
'uid' => self::USERNAME,
]);
$this->assertContains("User <" . self::USERNAME . "> in unknown", $commandTester->getDisplay());
$this->assertStringContainsString("User <" . self::USERNAME . "> in unknown", $commandTester->getDisplay());
}
public function testWithCorrectUserWithNoCalendars() {
@ -94,7 +93,7 @@ class ListCalendarsTest extends TestCase {
$commandTester->execute([
'uid' => self::USERNAME,
]);
$this->assertContains("User <" . self::USERNAME . "> has no calendars\n", $commandTester->getDisplay());
$this->assertStringContainsString("User <" . self::USERNAME . "> has no calendars\n", $commandTester->getDisplay());
}
public function dataExecute() {
@ -133,7 +132,7 @@ class ListCalendarsTest extends TestCase {
$commandTester->execute([
'uid' => self::USERNAME,
]);
$this->assertContains($output, $commandTester->getDisplay());
$this->assertNotContains(BirthdayService::BIRTHDAY_CALENDAR_URI, $commandTester->getDisplay());
$this->assertStringContainsString($output, $commandTester->getDisplay());
$this->assertStringNotContainsString(BirthdayService::BIRTHDAY_CALENDAR_URI, $commandTester->getDisplay());
}
}

View File

@ -121,7 +121,7 @@ class MoveCalendarTest extends TestCase {
]);
}
public function testMoveWithInexistantCalendar() {
$this->expectException(\InvalidArgumentException::class);
$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 @@ class MoveCalendarTest extends TestCase {
]);
}
public function testMoveWithExistingDestinationCalendar() {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('User <user2> already has a calendar named <personal>.');
@ -313,7 +313,7 @@ class MoveCalendarTest extends TestCase {
'destinationuid' => 'user2',
]);
$this->assertContains("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
$this->assertStringContainsString("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
}
public function testMoveWithDestinationNotPartOfGroupAndForce() {
@ -360,7 +360,7 @@ class MoveCalendarTest extends TestCase {
'--force' => true
]);
$this->assertContains("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
$this->assertStringContainsString("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
}
public function dataTestMoveWithCalendarAlreadySharedToDestination(): array {

View File

@ -60,6 +60,6 @@ class CleanupTest extends TestCase {
$this->assertEquals(0, $rc);
$output = $this->cmd->getDisplay();
$this->assertContains("All user-provider associations for provider u2f have been removed", $output);
$this->assertStringContainsString("All user-provider associations for provider u2f have been removed", $output);
}
}

View File

@ -67,7 +67,7 @@ class DisableTest extends TestCase {
]);
$this->assertEquals(1, $rc);
$this->assertContains("Invalid UID", $this->command->getDisplay());
$this->assertStringContainsString("Invalid UID", $this->command->getDisplay());
}
public function testEnableNotSupported() {
@ -87,7 +87,7 @@ class DisableTest extends TestCase {
]);
$this->assertEquals(2, $rc);
$this->assertContains("The provider does not support this operation", $this->command->getDisplay());
$this->assertStringContainsString("The provider does not support this operation", $this->command->getDisplay());
}
public function testEnabled() {
@ -107,6 +107,6 @@ class DisableTest extends TestCase {
]);
$this->assertEquals(0, $rc);
$this->assertContains("Two-factor provider totp disabled for user ricky", $this->command->getDisplay());
$this->assertStringContainsString("Two-factor provider totp disabled for user ricky", $this->command->getDisplay());
}
}

View File

@ -67,7 +67,7 @@ class EnableTest extends TestCase {
]);
$this->assertEquals(1, $rc);
$this->assertContains("Invalid UID", $this->command->getDisplay());
$this->assertStringContainsString("Invalid UID", $this->command->getDisplay());
}
public function testEnableNotSupported() {
@ -87,7 +87,7 @@ class EnableTest extends TestCase {
]);
$this->assertEquals(2, $rc);
$this->assertContains("The provider does not support this operation", $this->command->getDisplay());
$this->assertStringContainsString("The provider does not support this operation", $this->command->getDisplay());
}
public function testEnabled() {
@ -107,6 +107,6 @@ class EnableTest extends TestCase {
]);
$this->assertEquals(0, $rc);
$this->assertContains("Two-factor provider totp enabled for user belle", $this->command->getDisplay());
$this->assertStringContainsString("Two-factor provider totp enabled for user belle", $this->command->getDisplay());
}
}

View File

@ -64,7 +64,7 @@ class EnforceTest extends TestCase {
$this->assertEquals(0, $rc);
$display = $this->command->getDisplay();
$this->assertContains("Two-factor authentication is enforced for all users", $display);
$this->assertStringContainsString("Two-factor authentication is enforced for all users", $display);
}
public function testEnforceForOneGroup() {
@ -82,7 +82,7 @@ class EnforceTest extends TestCase {
$this->assertEquals(0, $rc);
$display = $this->command->getDisplay();
$this->assertContains("Two-factor authentication is enforced for members of the group(s) twofactorers", $display);
$this->assertStringContainsString("Two-factor authentication is enforced for members of the group(s) twofactorers", $display);
}
public function testEnforceForAllExceptOneGroup() {
@ -100,7 +100,7 @@ class EnforceTest extends TestCase {
$this->assertEquals(0, $rc);
$display = $this->command->getDisplay();
$this->assertContains("Two-factor authentication is enforced for all users, except members of yoloers", $display);
$this->assertStringContainsString("Two-factor authentication is enforced for all users, except members of yoloers", $display);
}
public function testDisableEnforced() {
@ -117,7 +117,7 @@ class EnforceTest extends TestCase {
$this->assertEquals(0, $rc);
$display = $this->command->getDisplay();
$this->assertContains("Two-factor authentication is not enforced", $display);
$this->assertStringContainsString("Two-factor authentication is not enforced", $display);
}
public function testCurrentStateEnabled() {
@ -129,7 +129,7 @@ class EnforceTest extends TestCase {
$this->assertEquals(0, $rc);
$display = $this->command->getDisplay();
$this->assertContains("Two-factor authentication is enforced for all users", $display);
$this->assertStringContainsString("Two-factor authentication is enforced for all users", $display);
}
public function testCurrentStateDisabled() {
@ -141,6 +141,6 @@ class EnforceTest extends TestCase {
$this->assertEquals(0, $rc);
$display = $this->command->getDisplay();
$this->assertContains("Two-factor authentication is not enforced", $display);
$this->assertStringContainsString("Two-factor authentication is not enforced", $display);
}
}

View File

@ -61,7 +61,7 @@ class StateTest extends TestCase {
]);
$output = $this->cmd->getDisplay();
$this->assertContains("Invalid UID", $output);
$this->assertStringContainsString("Invalid UID", $output);
}
public function testStateNoProvidersActive() {
@ -84,7 +84,7 @@ class StateTest extends TestCase {
]);
$output = $this->cmd->getDisplay();
$this->assertContains("Two-factor authentication is not enabled for user eldora", $output);
$this->assertStringContainsString("Two-factor authentication is not enabled for user eldora", $output);
}
public function testStateOneProviderActive() {
@ -107,6 +107,6 @@ class StateTest extends TestCase {
]);
$output = $this->cmd->getDisplay();
$this->assertContains("Two-factor authentication is enabled for user mohamed", $output);
$this->assertStringContainsString("Two-factor authentication is enabled for user mohamed", $output);
}
}

View File

@ -45,7 +45,7 @@ class DownloadResponseTest extends \Test\TestCase {
public function testHeaders() {
$headers = $this->response->getHeaders();
$this->assertContains('attachment; filename="file"', $headers['Content-Disposition']);
$this->assertContains('content', $headers['Content-Type']);
$this->assertStringContainsString('attachment; filename="file"', $headers['Content-Disposition']);
$this->assertStringContainsString('content', $headers['Content-Type']);
}
}