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
parent 403040255f
commit 3904acfe93
No known key found for this signature in database
GPG key ID: FE03C3A163FEDE68
8 changed files with 25 additions and 27 deletions

View file

@ -63,7 +63,6 @@ class ListCalendarsTest extends TestCase {
);
}
public function testWithBadUser()
{
$this->expectException(\InvalidArgumentException::class);
@ -77,7 +76,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()
@ -96,7 +95,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()
@ -137,7 +136,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,6 @@ class MoveCalendarTest extends TestCase {
]);
}
public function testMoveWithInexistantCalendar()
{
$this->expectException(\InvalidArgumentException::class);
@ -149,7 +148,7 @@ class MoveCalendarTest extends TestCase {
]);
}
public function testMoveWithExistingDestinationCalendar()
{
$this->expectException(\InvalidArgumentException::class);
@ -319,7 +318,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()
@ -367,7 +366,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,7 +60,7 @@ 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,7 +107,7 @@ 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,7 +141,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);
}
}

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,7 +107,7 @@ 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

@ -47,8 +47,8 @@ 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']);
}