minor #32977 Remove deprecated assertContains (MarioBlazek)

This PR was squashed before being merged into the 4.3 branch (closes #32977).

Discussion
----------

Remove deprecated assertContains

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32844
| License       | MIT
| Doc PR        | symfony

This PR replaces `assertContains()` with `assertStringContainsString()`.

Commits
-------

43acda6cf4 Remove deprecated assertContains
This commit is contained in:
Nicolas Grekas 2019-08-07 10:23:13 +02:00
commit 6d181ffbb6
32 changed files with 76 additions and 76 deletions

View File

@ -46,8 +46,8 @@ class DeprecationTest extends TestCase
public function testItCanBeConvertedToAString() public function testItCanBeConvertedToAString()
{ {
$deprecation = new Deprecation('💩', $this->debugBacktrace(), __FILE__); $deprecation = new Deprecation('💩', $this->debugBacktrace(), __FILE__);
$this->assertContains('💩', $deprecation->toString()); $this->assertStringContainsString('💩', $deprecation->toString());
$this->assertContains(__FUNCTION__, $deprecation->toString()); $this->assertStringContainsString(__FUNCTION__, $deprecation->toString());
} }
public function testItRulesOutFilesOutsideVendorsAsIndirect() public function testItRulesOutFilesOutsideVendorsAsIndirect()

View File

@ -45,7 +45,7 @@ class CachePoolDeleteCommandTest extends TestCase
$tester = $this->getCommandTester($this->getKernel()); $tester = $this->getCommandTester($this->getKernel());
$tester->execute(['pool' => 'foo', 'key' => 'bar']); $tester->execute(['pool' => 'foo', 'key' => 'bar']);
$this->assertContains('[OK] Cache item "bar" was successfully deleted.', $tester->getDisplay()); $this->assertStringContainsString('[OK] Cache item "bar" was successfully deleted.', $tester->getDisplay());
} }
public function testCommandWithInValidKey() public function testCommandWithInValidKey()
@ -62,7 +62,7 @@ class CachePoolDeleteCommandTest extends TestCase
$tester = $this->getCommandTester($this->getKernel()); $tester = $this->getCommandTester($this->getKernel());
$tester->execute(['pool' => 'foo', 'key' => 'bar']); $tester->execute(['pool' => 'foo', 'key' => 'bar']);
$this->assertContains('[NOTE] Cache item "bar" does not exist in cache pool "foo".', $tester->getDisplay()); $this->assertStringContainsString('[NOTE] Cache item "bar" does not exist in cache pool "foo".', $tester->getDisplay());
} }
public function testCommandDeleteFailed() public function testCommandDeleteFailed()

View File

@ -69,7 +69,7 @@ EOF;
); );
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success'); $this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('[OK] All 0 XLIFF files contain valid syntax', trim($tester->getDisplay())); $this->assertStringContainsString('[OK] All 0 XLIFF files contain valid syntax', trim($tester->getDisplay()));
} }
/** /**

View File

@ -226,7 +226,7 @@ class ApplicationTest extends TestCase
$this->assertSame(0, $tester->getStatusCode()); $this->assertSame(0, $tester->getStatusCode());
$display = explode('Lists commands', $tester->getDisplay()); $display = explode('Lists commands', $tester->getDisplay());
$this->assertContains(trim('[WARNING] Some commands could not be registered:'), trim($display[1])); $this->assertStringContainsString(trim('[WARNING] Some commands could not be registered:'), trim($display[1]));
} }
public function testSuggestingPackagesWithExactMatch() public function testSuggestingPackagesWithExactMatch()

View File

@ -31,8 +31,8 @@ class CachePoolListCommandTest extends AbstractWebTestCase
$tester->execute([]); $tester->execute([]);
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:list exits with 0 in case of success'); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:list exits with 0 in case of success');
$this->assertContains('cache.app', $tester->getDisplay()); $this->assertStringContainsString('cache.app', $tester->getDisplay());
$this->assertContains('cache.system', $tester->getDisplay()); $this->assertStringContainsString('cache.system', $tester->getDisplay());
} }
public function testEmptyList() public function testEmptyList()

View File

@ -71,7 +71,7 @@ class ConfigDebugCommandTest extends AbstractWebTestCase
$tester = $this->createCommandTester(); $tester = $this->createCommandTester();
$tester->execute(['name' => 'FrameworkBundle']); $tester->execute(['name' => 'FrameworkBundle']);
$this->assertContains("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay()); $this->assertStringContainsString("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
} }
/** /**

View File

@ -61,8 +61,8 @@ class ContainerDebugCommandTest extends AbstractWebTestCase
$this->assertNotContains('private_alias', $tester->getDisplay()); $this->assertNotContains('private_alias', $tester->getDisplay());
$tester->run(['command' => 'debug:container']); $tester->run(['command' => 'debug:container']);
$this->assertContains('public', $tester->getDisplay()); $this->assertStringContainsString('public', $tester->getDisplay());
$this->assertContains('private_alias', $tester->getDisplay()); $this->assertStringContainsString('private_alias', $tester->getDisplay());
} }
/** /**
@ -130,7 +130,7 @@ TXT
$tester = new ApplicationTester($application); $tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:container', '--env-var' => 'js'], ['decorated' => false]); $tester->run(['command' => 'debug:container', '--env-var' => 'js'], ['decorated' => false]);
$this->assertContains(file_get_contents(__DIR__.'/Fixtures/describe_env_vars.txt'), $tester->getDisplay(true)); $this->assertStringContainsString(file_get_contents(__DIR__.'/Fixtures/describe_env_vars.txt'), $tester->getDisplay(true));
} }
public function provideIgnoreBackslashWhenFindingService() public function provideIgnoreBackslashWhenFindingService()

View File

@ -56,7 +56,7 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application); $tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'HttpKernelHttpKernelInterface']); $tester->run(['command' => 'debug:autowiring', 'search' => 'HttpKernelHttpKernelInterface']);
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay()); $this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
} }
public function testSearchNoResults() public function testSearchNoResults()
@ -83,7 +83,7 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application); $tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect']); $tester->run(['command' => 'debug:autowiring', 'search' => 'redirect']);
$this->assertContains(' more concrete service would be displayed when adding the "--all" option.', $tester->getDisplay()); $this->assertStringContainsString(' more concrete service would be displayed when adding the "--all" option.', $tester->getDisplay());
} }
public function testSearchNotAliasedServiceWithAll() public function testSearchNotAliasedServiceWithAll()
@ -95,6 +95,6 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application); $tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]); $tester->run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]);
$this->assertContains('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay()); $this->assertStringContainsString('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
} }
} }

View File

@ -34,9 +34,9 @@ class RouterDebugCommandTest extends AbstractWebTestCase
$display = $tester->getDisplay(); $display = $tester->getDisplay();
$this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('routerdebug_test', $display); $this->assertStringContainsString('routerdebug_test', $display);
$this->assertContains('/test', $display); $this->assertStringContainsString('/test', $display);
$this->assertContains('/session', $display); $this->assertStringContainsString('/session', $display);
} }
public function testDumpOneRoute() public function testDumpOneRoute()
@ -45,8 +45,8 @@ class RouterDebugCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['name' => 'routerdebug_session_welcome']); $ret = $tester->execute(['name' => 'routerdebug_session_welcome']);
$this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('routerdebug_session_welcome', $tester->getDisplay()); $this->assertStringContainsString('routerdebug_session_welcome', $tester->getDisplay());
$this->assertContains('/session', $tester->getDisplay()); $this->assertStringContainsString('/session', $tester->getDisplay());
} }
public function testSearchMultipleRoutes() public function testSearchMultipleRoutes()
@ -56,9 +56,9 @@ class RouterDebugCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['name' => 'routerdebug'], ['interactive' => true]); $ret = $tester->execute(['name' => 'routerdebug'], ['interactive' => true]);
$this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('Select one of the matching routes:', $tester->getDisplay()); $this->assertStringContainsString('Select one of the matching routes:', $tester->getDisplay());
$this->assertContains('routerdebug_test', $tester->getDisplay()); $this->assertStringContainsString('routerdebug_test', $tester->getDisplay());
$this->assertContains('/test', $tester->getDisplay()); $this->assertStringContainsString('/test', $tester->getDisplay());
} }
public function testSearchWithThrow() public function testSearchWithThrow()

View File

@ -33,13 +33,13 @@ class TranslationDebugCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['locale' => 'en']); $ret = $tester->execute(['locale' => 'en']);
$this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('missing messages hello_from_construct_arg_service', $tester->getDisplay()); $this->assertStringContainsString('missing messages hello_from_construct_arg_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_subscriber_service', $tester->getDisplay()); $this->assertStringContainsString('missing messages hello_from_subscriber_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_property_service', $tester->getDisplay()); $this->assertStringContainsString('missing messages hello_from_property_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_method_calls_service', $tester->getDisplay()); $this->assertStringContainsString('missing messages hello_from_method_calls_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_controller', $tester->getDisplay()); $this->assertStringContainsString('missing messages hello_from_controller', $tester->getDisplay());
$this->assertContains('unused validators This value should be blank.', $tester->getDisplay()); $this->assertStringContainsString('unused validators This value should be blank.', $tester->getDisplay());
$this->assertContains('unused security Invalid CSRF token.', $tester->getDisplay()); $this->assertStringContainsString('unused security Invalid CSRF token.', $tester->getDisplay());
} }
private function createCommandTester(): CommandTester private function createCommandTester(): CommandTester

View File

@ -109,7 +109,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
], ['interactive' => false]); ], ['interactive' => false]);
$output = $this->passwordEncoderCommandTester->getDisplay(); $output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertContains('Password encoding succeeded', $output); $this->assertStringContainsString('Password encoding succeeded', $output);
$encoder = new NativePasswordEncoder(); $encoder = new NativePasswordEncoder();
preg_match('# Encoded password\s{1,}([\w+\/$.,=]+={0,2})\s+#', $output, $matches); preg_match('# Encoded password\s{1,}([\w+\/$.,=]+={0,2})\s+#', $output, $matches);
@ -130,7 +130,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
], ['interactive' => false]); ], ['interactive' => false]);
$output = $this->passwordEncoderCommandTester->getDisplay(); $output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertContains('Password encoding succeeded', $output); $this->assertStringContainsString('Password encoding succeeded', $output);
preg_match('# Encoded password\s+(\$?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches); preg_match('# Encoded password\s+(\$?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
$hash = $matches[1]; $hash = $matches[1];

View File

@ -159,9 +159,9 @@ class HttpBrowserTest extends AbstractBrowserTest
->expects($this->once()) ->expects($this->once())
->method('request') ->method('request')
->with('POST', 'http://example.com/', $this->callback(function ($options) { ->with('POST', 'http://example.com/', $this->callback(function ($options) {
$this->assertContains('Content-Type: multipart/form-data', implode('', $options['headers'])); $this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
$this->assertInstanceOf('\Generator', $options['body']); $this->assertInstanceOf('\Generator', $options['body']);
$this->assertContains('my_file', implode('', iterator_to_array($options['body']))); $this->assertStringContainsString('my_file', implode('', iterator_to_array($options['body'])));
return true; return true;
})) }))

View File

@ -506,9 +506,9 @@ class ApplicationTest extends TestCase
$tester->setInputs(['y']); $tester->setInputs(['y']);
$tester->run(['command' => 'foos'], ['decorated' => false]); $tester->run(['command' => 'foos'], ['decorated' => false]);
$display = trim($tester->getDisplay(true)); $display = trim($tester->getDisplay(true));
$this->assertContains('Command "foos" is not defined', $display); $this->assertStringContainsString('Command "foos" is not defined', $display);
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display); $this->assertStringContainsString('Do you want to run "foo" instead? (yes/no) [no]:', $display);
$this->assertContains('called', $display); $this->assertStringContainsString('called', $display);
} }
public function testDontRunAlternativeCommandName() public function testDontRunAlternativeCommandName()
@ -521,8 +521,8 @@ class ApplicationTest extends TestCase
$exitCode = $tester->run(['command' => 'foos'], ['decorated' => false]); $exitCode = $tester->run(['command' => 'foos'], ['decorated' => false]);
$this->assertSame(1, $exitCode); $this->assertSame(1, $exitCode);
$display = trim($tester->getDisplay(true)); $display = trim($tester->getDisplay(true));
$this->assertContains('Command "foos" is not defined', $display); $this->assertStringContainsString('Command "foos" is not defined', $display);
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display); $this->assertStringContainsString('Do you want to run "foo" instead? (yes/no) [no]:', $display);
} }
public function provideInvalidCommandNamesSingle() public function provideInvalidCommandNamesSingle()
@ -854,7 +854,7 @@ class ApplicationTest extends TestCase
$tester = new ApplicationTester($application); $tester = new ApplicationTester($application);
$tester->run(['command' => 'foo'], ['decorated' => false]); $tester->run(['command' => 'foo'], ['decorated' => false]);
$this->assertContains('[InvalidArgumentException@anonymous]', $tester->getDisplay(true)); $this->assertStringContainsString('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
$application = new Application(); $application = new Application();
$application->setAutoExit(false); $application->setAutoExit(false);
@ -865,7 +865,7 @@ class ApplicationTest extends TestCase
$tester = new ApplicationTester($application); $tester = new ApplicationTester($application);
$tester->run(['command' => 'foo'], ['decorated' => false]); $tester->run(['command' => 'foo'], ['decorated' => false]);
$this->assertContains('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true)); $this->assertStringContainsString('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true));
} }
public function testRenderExceptionStackTraceContainsRootException() public function testRenderExceptionStackTraceContainsRootException()
@ -879,7 +879,7 @@ class ApplicationTest extends TestCase
$tester = new ApplicationTester($application); $tester = new ApplicationTester($application);
$tester->run(['command' => 'foo'], ['decorated' => false]); $tester->run(['command' => 'foo'], ['decorated' => false]);
$this->assertContains('[InvalidArgumentException@anonymous]', $tester->getDisplay(true)); $this->assertStringContainsString('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
$application = new Application(); $application = new Application();
$application->setAutoExit(false); $application->setAutoExit(false);

View File

@ -58,7 +58,7 @@ content="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgndGVzdDMnKTwvc2NyaXB0Pg"
$handler->sendPhpResponse(new \RuntimeException($htmlWithXss)); $handler->sendPhpResponse(new \RuntimeException($htmlWithXss));
$response = ob_get_clean(); $response = ob_get_clean();
$this->assertContains(sprintf('<h1 class="break-long-words exception-message">%s</h1>', htmlspecialchars($htmlWithXss, ENT_COMPAT | ENT_SUBSTITUTE, 'UTF-8')), $response); $this->assertStringContainsString(sprintf('<h1 class="break-long-words exception-message">%s</h1>', htmlspecialchars($htmlWithXss, ENT_COMPAT | ENT_SUBSTITUTE, 'UTF-8')), $response);
} }
public function testStatusCode() public function testStatusCode()

View File

@ -31,6 +31,6 @@ class CustomExpressionLanguageFunctionTest extends TestCase
$dump = new PhpDumper($container); $dump = new PhpDumper($container);
$dumped = $dump->dump(); $dumped = $dump->dump();
$this->assertContains('strtolower("foobar")', $dumped); $this->assertStringContainsString('strtolower("foobar")', $dumped);
} }
} }

View File

@ -72,7 +72,7 @@ TXT
$tester->execute(['class' => 'DateTime'], ['decorated' => false, 'interactive' => false]); $tester->execute(['class' => 'DateTime'], ['decorated' => false, 'interactive' => false]);
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success'); $this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('Symfony\Component\Form\Extension\Core\Type\DateTimeType (Block prefix: "datetime")', $tester->getDisplay()); $this->assertStringContainsString('Symfony\Component\Form\Extension\Core\Type\DateTimeType (Block prefix: "datetime")', $tester->getDisplay());
} }
public function testDebugFormTypeOption() public function testDebugFormTypeOption()

View File

@ -29,7 +29,7 @@ class ResponseIsRedirectedTest extends TestCase
try { try {
$constraint->evaluate(new Response()); $constraint->evaluate(new Response());
} catch (ExpectationFailedException $e) { } catch (ExpectationFailedException $e) {
$this->assertContains("Failed asserting that the Response is redirected.\nHTTP/1.0 200 OK", TestFailure::exceptionToString($e)); $this->assertStringContainsString("Failed asserting that the Response is redirected.\nHTTP/1.0 200 OK", TestFailure::exceptionToString($e));
return; return;
} }

View File

@ -29,7 +29,7 @@ class ResponseIsSuccessfulTest extends TestCase
try { try {
$constraint->evaluate(new Response('', 404)); $constraint->evaluate(new Response('', 404));
} catch (ExpectationFailedException $e) { } catch (ExpectationFailedException $e) {
$this->assertContains("Failed asserting that the Response is successful.\nHTTP/1.0 404 Not Found", TestFailure::exceptionToString($e)); $this->assertStringContainsString("Failed asserting that the Response is successful.\nHTTP/1.0 404 Not Found", TestFailure::exceptionToString($e));
return; return;
} }

View File

@ -31,7 +31,7 @@ class ResponseStatusCodeSameTest extends TestCase
try { try {
$constraint->evaluate(new Response('', 404)); $constraint->evaluate(new Response('', 404));
} catch (ExpectationFailedException $e) { } catch (ExpectationFailedException $e) {
$this->assertContains("Failed asserting that the Response status code is 200.\nHTTP/1.0 404 Not Found", TestFailure::exceptionToString($e)); $this->assertStringContainsString("Failed asserting that the Response status code is 200.\nHTTP/1.0 404 Not Found", TestFailure::exceptionToString($e));
return; return;
} }

View File

@ -218,7 +218,7 @@ class HttpKernelTest extends TestCase
// `file` index the array starting at 0, and __FILE__ starts at 1 // `file` index the array starting at 0, and __FILE__ starts at 1
$line = file($first['file'])[$first['line'] - 2]; $line = file($first['file'])[$first['line'] - 2];
$this->assertContains('// call controller', $line); $this->assertStringContainsString('// call controller', $line);
} }
} }

View File

@ -188,7 +188,7 @@ class LdapManagerTest extends LdapTestCase
$newEntry = $result[0]; $newEntry = $result[0];
$originalCN = $entry->getAttribute('cn')[0]; $originalCN = $entry->getAttribute('cn')[0];
$this->assertContains($originalCN, $newEntry->getAttribute('cn')); $this->assertStringContainsString($originalCN, $newEntry->getAttribute('cn'));
$entryManager->rename($newEntry, 'cn='.$originalCN); $entryManager->rename($newEntry, 'cn='.$originalCN);
@ -357,6 +357,6 @@ class LdapManagerTest extends LdapTestCase
$result = $this->executeSearchQuery(1); $result = $this->executeSearchQuery(1);
$movedEntry = $result[0]; $movedEntry = $result[0];
$this->assertContains('ou=Ldap', $movedEntry->getDn()); $this->assertStringContainsString('ou=Ldap', $movedEntry->getDn());
} }
} }

View File

@ -244,7 +244,7 @@ class TransportTest extends TestCase
$this->assertInstanceOf(Amazon\Smtp\SesTransport::class, $transport); $this->assertInstanceOf(Amazon\Smtp\SesTransport::class, $transport);
$this->assertEquals('u$er', $transport->getUsername()); $this->assertEquals('u$er', $transport->getUsername());
$this->assertEquals('pa$s', $transport->getPassword()); $this->assertEquals('pa$s', $transport->getPassword());
$this->assertContains('.sun.', $transport->getStream()->getHost()); $this->assertStringContainsString('.sun.', $transport->getStream()->getHost());
$this->assertProperties($transport, $dispatcher, $logger); $this->assertProperties($transport, $dispatcher, $logger);
$client = $this->createMock(HttpClientInterface::class); $client = $this->createMock(HttpClientInterface::class);

View File

@ -62,7 +62,7 @@ class ConsumeMessagesCommandTest extends TestCase
]); ]);
$this->assertSame(0, $tester->getStatusCode()); $this->assertSame(0, $tester->getStatusCode());
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); $this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
} }
public function testRunWithBusOption() public function testRunWithBusOption()
@ -95,7 +95,7 @@ class ConsumeMessagesCommandTest extends TestCase
]); ]);
$this->assertSame(0, $tester->getStatusCode()); $this->assertSame(0, $tester->getStatusCode());
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); $this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
} }
public function testBasicRunWithBusLocator() public function testBasicRunWithBusLocator()
@ -127,7 +127,7 @@ class ConsumeMessagesCommandTest extends TestCase
]); ]);
$this->assertSame(0, $tester->getStatusCode()); $this->assertSame(0, $tester->getStatusCode());
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); $this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
} }
public function testRunWithBusOptionAndBusLocator() public function testRunWithBusOptionAndBusLocator()
@ -160,6 +160,6 @@ class ConsumeMessagesCommandTest extends TestCase
]); ]);
$this->assertSame(0, $tester->getStatusCode()); $this->assertSame(0, $tester->getStatusCode());
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); $this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
} }
} }

View File

@ -32,6 +32,6 @@ class FailedMessagesRemoveCommandTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['id' => 20, '--force' => true]); $tester->execute(['id' => 20, '--force' => true]);
$this->assertContains('Message removed.', $tester->getDisplay()); $this->assertStringContainsString('Message removed.', $tester->getDisplay());
} }
} }

View File

@ -44,6 +44,6 @@ class FailedMessagesRetryCommandTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['id' => [10, 12]]); $tester->execute(['id' => [10, 12]]);
$this->assertContains('[OK]', $tester->getDisplay()); $this->assertStringContainsString('[OK]', $tester->getDisplay());
} }
} }

View File

@ -45,7 +45,7 @@ class FailedMessagesShowCommandTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['id' => 15]); $tester->execute(['id' => 15]);
$this->assertContains(sprintf(<<<EOF $this->assertStringContainsString(sprintf(<<<EOF
------------- --------------------- ------------- ---------------------
Class stdClass Class stdClass
Message Id 15 Message Id 15

View File

@ -42,8 +42,8 @@ class SetupTransportsCommandTest extends TestCase
$tester->execute([]); $tester->execute([]);
$display = $tester->getDisplay(); $display = $tester->getDisplay();
$this->assertContains('The "amqp" transport was setup successfully.', $display); $this->assertStringContainsString('The "amqp" transport was setup successfully.', $display);
$this->assertContains('The "other_transport" transport does not support setup.', $display); $this->assertStringContainsString('The "other_transport" transport does not support setup.', $display);
} }
public function testReceiverNameArgument() public function testReceiverNameArgument()
@ -66,7 +66,7 @@ class SetupTransportsCommandTest extends TestCase
$tester->execute(['transport' => 'amqp']); $tester->execute(['transport' => 'amqp']);
$display = $tester->getDisplay(); $display = $tester->getDisplay();
$this->assertContains('The "amqp" transport was setup successfully.', $display); $this->assertStringContainsString('The "amqp" transport was setup successfully.', $display);
} }
public function testReceiverNameArgumentNotFound() public function testReceiverNameArgumentNotFound()

View File

@ -330,7 +330,7 @@ class EmailTest extends TestCase
$this->assertCount(2, $parts = $related[0]->getParts()); $this->assertCount(2, $parts = $related[0]->getParts());
$this->assertInstanceOf(AlternativePart::class, $parts[0]); $this->assertInstanceOf(AlternativePart::class, $parts[0]);
$generatedHtml = $parts[0]->getParts()[1]; $generatedHtml = $parts[0]->getParts()[1];
$this->assertContains('cid:'.$parts[1]->getContentId(), $generatedHtml->getBody()); $this->assertStringContainsString('cid:'.$parts[1]->getContentId(), $generatedHtml->getBody());
$content = 'html content <img src="cid:test.gif">'; $content = 'html content <img src="cid:test.gif">';
$r = fopen('php://memory', 'r+', false); $r = fopen('php://memory', 'r+', false);

View File

@ -23,9 +23,9 @@ class MessagePartTest extends TestCase
public function testConstructor() public function testConstructor()
{ {
$p = new MessagePart((new Email())->from('fabien@symfony.com')->text('content')); $p = new MessagePart((new Email())->from('fabien@symfony.com')->text('content'));
$this->assertContains('content', $p->getBody()); $this->assertStringContainsString('content', $p->getBody());
$this->assertContains('content', $p->bodyToString()); $this->assertStringContainsString('content', $p->bodyToString());
$this->assertContains('content', implode('', iterator_to_array($p->bodyToIterable()))); $this->assertStringContainsString('content', implode('', iterator_to_array($p->bodyToIterable())));
$this->assertEquals('message', $p->getMediaType()); $this->assertEquals('message', $p->getMediaType());
$this->assertEquals('rfc822', $p->getMediaSubType()); $this->assertEquals('rfc822', $p->getMediaSubType());
} }

View File

@ -37,7 +37,7 @@ class XliffLintCommandTest extends TestCase
); );
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success'); $this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('OK', trim($tester->getDisplay())); $this->assertStringContainsString('OK', trim($tester->getDisplay()));
} }
public function testLintCorrectFiles() public function testLintCorrectFiles()
@ -52,7 +52,7 @@ class XliffLintCommandTest extends TestCase
); );
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success'); $this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('OK', trim($tester->getDisplay())); $this->assertStringContainsString('OK', trim($tester->getDisplay()));
} }
/** /**
@ -69,7 +69,7 @@ class XliffLintCommandTest extends TestCase
); );
$this->assertEquals($mustFail ? 1 : 0, $tester->getStatusCode()); $this->assertEquals($mustFail ? 1 : 0, $tester->getStatusCode());
$this->assertContains($mustFail ? '[WARNING] 0 XLIFF files have valid syntax and 1 contain errors.' : '[OK] All 1 XLIFF files contain valid syntax.', $tester->getDisplay()); $this->assertStringContainsString($mustFail ? '[WARNING] 0 XLIFF files have valid syntax and 1 contain errors.' : '[OK] All 1 XLIFF files contain valid syntax.', $tester->getDisplay());
} }
public function testLintIncorrectXmlSyntax() public function testLintIncorrectXmlSyntax()
@ -80,7 +80,7 @@ class XliffLintCommandTest extends TestCase
$tester->execute(['filename' => $filename], ['decorated' => false]); $tester->execute(['filename' => $filename], ['decorated' => false]);
$this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error'); $this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error');
$this->assertContains('Opening and ending tag mismatch: target line 6 and source', trim($tester->getDisplay())); $this->assertStringContainsString('Opening and ending tag mismatch: target line 6 and source', trim($tester->getDisplay()));
} }
public function testLintIncorrectTargetLanguage() public function testLintIncorrectTargetLanguage()
@ -91,7 +91,7 @@ class XliffLintCommandTest extends TestCase
$tester->execute(['filename' => $filename], ['decorated' => false]); $tester->execute(['filename' => $filename], ['decorated' => false]);
$this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error'); $this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error');
$this->assertContains('There is a mismatch between the language included in the file name ("messages.en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay())); $this->assertStringContainsString('There is a mismatch between the language included in the file name ("messages.en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay()));
} }
public function testLintTargetLanguageIsCaseInsensitive() public function testLintTargetLanguageIsCaseInsensitive()
@ -102,7 +102,7 @@ class XliffLintCommandTest extends TestCase
$tester->execute(['filename' => $filename], ['decorated' => false]); $tester->execute(['filename' => $filename], ['decorated' => false]);
$this->assertEquals(0, $tester->getStatusCode()); $this->assertEquals(0, $tester->getStatusCode());
$this->assertContains('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay())); $this->assertStringContainsString('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay()));
} }
public function testLintFileNotReadable() public function testLintFileNotReadable()

View File

@ -446,7 +446,7 @@ abstract class HttpClientTestCase extends TestCase
$body = $response->toArray(); $body = $response->toArray();
$this->assertContains('json', $body['content-type']); $this->assertStringContainsString('json', $body['content-type']);
unset($body['content-type']); unset($body['content-type']);
$this->assertSame(['foo' => 'bar', 'REQUEST_METHOD' => 'POST'], $body); $this->assertSame(['foo' => 'bar', 'REQUEST_METHOD' => 'POST'], $body);
} }
@ -705,11 +705,11 @@ abstract class HttpClientTestCase extends TestCase
$headers = $response->getHeaders(); $headers = $response->getHeaders();
$this->assertSame(['Accept-Encoding'], $headers['vary']); $this->assertSame(['Accept-Encoding'], $headers['vary']);
$this->assertContains('gzip', $headers['content-encoding'][0]); $this->assertStringContainsString('gzip', $headers['content-encoding'][0]);
$body = $response->toArray(); $body = $response->toArray();
$this->assertContains('gzip', $body['HTTP_ACCEPT_ENCODING']); $this->assertStringContainsString('gzip', $body['HTTP_ACCEPT_ENCODING']);
} }
public function testBaseUri() public function testBaseUri()
@ -757,7 +757,7 @@ abstract class HttpClientTestCase extends TestCase
$headers = $response->getHeaders(); $headers = $response->getHeaders();
$this->assertSame(['Accept-Encoding'], $headers['vary']); $this->assertSame(['Accept-Encoding'], $headers['vary']);
$this->assertContains('gzip', $headers['content-encoding'][0]); $this->assertStringContainsString('gzip', $headers['content-encoding'][0]);
$body = $response->getContent(); $body = $response->getContent();
$this->assertSame("\x1F", $body[0]); $this->assertSame("\x1F", $body[0]);