]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use assertStringContainsString instead of assertContains on strings
authorMorris Jobke <hey@morrisjobke.de>
Thu, 23 Jul 2020 11:36:32 +0000 (13:36 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 23 Jul 2020 15:11:29 +0000 (17:11 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
apps/dav/tests/unit/Command/ListCalendarsTest.php
apps/dav/tests/unit/Command/MoveCalendarTest.php
tests/Core/Command/TwoFactorAuth/CleanupTest.php
tests/Core/Command/TwoFactorAuth/DisableTest.php
tests/Core/Command/TwoFactorAuth/EnableTest.php
tests/Core/Command/TwoFactorAuth/EnforceTest.php
tests/Core/Command/TwoFactorAuth/StateTest.php
tests/lib/AppFramework/Http/DownloadResponseTest.php

index b63a973668ef3f71b4fd23209bc57259e164fc41..c7dae373c94825e0adad0a443cad80aae602c8e2 100644 (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());
        }
 }
index a05674017277aa4b21fe33fa814a23b2ae7d6347..750863175a2d6c8274900438aaa104f265d3b1f7 100644 (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 {
index 98425aee2231226669eec094223a11dd23429a75..75e869ad06f7cff0355920a5ab58e8286b2fcf8d 100644 (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);
        }
 }
index fc0def50b90f4c9e3f539d51cf105212b2dd5a0b..5accaccb907e8d0081106581f954f54bc7ea0ee4 100644 (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());
        }
 }
index f3b66912f43c646274a267fc90a256e1a869eca1..fc71cc32148add94af51148c52862f7067cb3aa5 100644 (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());
        }
 }
index 48c09f7e63990884be6db1128c083c8973f11ed5..ed3deaa3fb341600ff9c85f1de4a044a81a317b9 100644 (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);
        }
 }
index ce52bcf2751fe154b3414e71528c08d00a94f748..54ab85b51b80eaa394b53529b3df93ca2f9fd12f 100644 (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);
        }
 }
index 1ad53f5db1348da92e1a11764e7fb1e2145ce3b6..6c509b8bc59f9a227b354bdb7c65e76b4f0e8654 100644 (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']);
        }
 }