Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated assertContains #32977

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function testLegacyTestMethodIsDetectedAsSuch()
public function testItCanBeConvertedToAString()
{
$deprecation = new Deprecation('💩', $this->debugBacktrace(), __FILE__);
$this->assertContains('💩', $deprecation->toString());
$this->assertContains(__FUNCTION__, $deprecation->toString());
$this->assertStringContainsString('💩', $deprecation->toString());
$this->assertStringContainsString(__FUNCTION__, $deprecation->toString());
}

public function testItRulesOutFilesOutsideVendorsAsIndirect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testCommandWithValidKey()
$tester = $this->getCommandTester($this->getKernel());
$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()
Expand All @@ -62,7 +62,7 @@ public function testCommandWithInValidKey()
$tester = $this->getCommandTester($this->getKernel());
$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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testLintFilesFromBundleDirectory()
);

$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()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd()
$this->assertSame(0, $tester->getStatusCode());
$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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function testListPools()
$tester->execute([]);

$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:list exits with 0 in case of success');
$this->assertContains('cache.app', $tester->getDisplay());
$this->assertContains('cache.system', $tester->getDisplay());
$this->assertStringContainsString('cache.app', $tester->getDisplay());
$this->assertStringContainsString('cache.system', $tester->getDisplay());
}

public function testEmptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testDumpWithPrefixedEnv()
$tester = $this->createCommandTester();
$tester->execute(['name' => 'FrameworkBundle']);

$this->assertContains("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
$this->assertStringContainsString("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function testPrivateAlias()
$this->assertNotContains('private_alias', $tester->getDisplay());

$tester->run(['command' => 'debug:container']);
$this->assertContains('public', $tester->getDisplay());
$this->assertContains('private_alias', $tester->getDisplay());
$this->assertStringContainsString('public', $tester->getDisplay());
$this->assertStringContainsString('private_alias', $tester->getDisplay());
}

/**
Expand Down Expand Up @@ -130,7 +130,7 @@ public function testDescribeEnvVar()
$tester = new ApplicationTester($application);
$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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testSearchIgnoreBackslashWhenFindingService()

$tester = new ApplicationTester($application);
$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()
Expand All @@ -83,7 +83,7 @@ public function testSearchNotAliasedService()
$tester = new ApplicationTester($application);
$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()
Expand All @@ -95,6 +95,6 @@ public function testSearchNotAliasedServiceWithAll()

$tester = new ApplicationTester($application);
$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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function testDumpAllRoutes()
$display = $tester->getDisplay();

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('routerdebug_test', $display);
$this->assertContains('/test', $display);
$this->assertContains('/session', $display);
$this->assertStringContainsString('routerdebug_test', $display);
$this->assertStringContainsString('/test', $display);
$this->assertStringContainsString('/session', $display);
}

public function testDumpOneRoute()
Expand All @@ -45,8 +45,8 @@ public function testDumpOneRoute()
$ret = $tester->execute(['name' => 'routerdebug_session_welcome']);

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('routerdebug_session_welcome', $tester->getDisplay());
$this->assertContains('/session', $tester->getDisplay());
$this->assertStringContainsString('routerdebug_session_welcome', $tester->getDisplay());
$this->assertStringContainsString('/session', $tester->getDisplay());
}

public function testSearchMultipleRoutes()
Expand All @@ -56,9 +56,9 @@ public function testSearchMultipleRoutes()
$ret = $tester->execute(['name' => 'routerdebug'], ['interactive' => true]);

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('Select one of the matching routes:', $tester->getDisplay());
$this->assertContains('routerdebug_test', $tester->getDisplay());
$this->assertContains('/test', $tester->getDisplay());
$this->assertStringContainsString('Select one of the matching routes:', $tester->getDisplay());
$this->assertStringContainsString('routerdebug_test', $tester->getDisplay());
$this->assertStringContainsString('/test', $tester->getDisplay());
}

public function testSearchWithThrow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public function testDumpAllTrans()
$ret = $tester->execute(['locale' => 'en']);

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('missing messages hello_from_construct_arg_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_subscriber_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_property_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_method_calls_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_controller', $tester->getDisplay());
$this->assertContains('unused validators This value should be blank.', $tester->getDisplay());
$this->assertContains('unused security Invalid CSRF token.', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_construct_arg_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_subscriber_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_property_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_method_calls_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_controller', $tester->getDisplay());
$this->assertStringContainsString('unused validators This value should be blank.', $tester->getDisplay());
$this->assertStringContainsString('unused security Invalid CSRF token.', $tester->getDisplay());
}

private function createCommandTester(): CommandTester
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function testEncodePasswordNative()
], ['interactive' => false]);

$output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertContains('Password encoding succeeded', $output);
$this->assertStringContainsString('Password encoding succeeded', $output);

$encoder = new NativePasswordEncoder();
preg_match('# Encoded password\s{1,}([\w+\/$.,=]+={0,2})\s+#', $output, $matches);
Expand All @@ -130,7 +130,7 @@ public function testEncodePasswordSodium()
], ['interactive' => false]);

$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);
$hash = $matches[1];
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ public function testMultiPartRequest()
->expects($this->once())
->method('request')
->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->assertContains('my_file', implode('', iterator_to_array($options['body'])));
$this->assertStringContainsString('my_file', implode('', iterator_to_array($options['body'])));

return true;
}))
Expand Down
Empty file.
16 changes: 8 additions & 8 deletions src/Symfony/Component/Console/Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,9 @@ public function testCanRunAlternativeCommandName()
$tester->setInputs(['y']);
$tester->run(['command' => 'foos'], ['decorated' => false]);
$display = trim($tester->getDisplay(true));
$this->assertContains('Command "foos" is not defined', $display);
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display);
$this->assertContains('called', $display);
$this->assertStringContainsString('Command "foos" is not defined', $display);
$this->assertStringContainsString('Do you want to run "foo" instead? (yes/no) [no]:', $display);
$this->assertStringContainsString('called', $display);
}

public function testDontRunAlternativeCommandName()
Expand All @@ -521,8 +521,8 @@ public function testDontRunAlternativeCommandName()
$exitCode = $tester->run(['command' => 'foos'], ['decorated' => false]);
$this->assertSame(1, $exitCode);
$display = trim($tester->getDisplay(true));
$this->assertContains('Command "foos" is not defined', $display);
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display);
$this->assertStringContainsString('Command "foos" is not defined', $display);
$this->assertStringContainsString('Do you want to run "foo" instead? (yes/no) [no]:', $display);
}

public function provideInvalidCommandNamesSingle()
Expand Down Expand Up @@ -854,7 +854,7 @@ public function testRenderAnonymousException()
$tester = new ApplicationTester($application);

$tester->run(['command' => 'foo'], ['decorated' => false]);
$this->assertContains('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
$this->assertStringContainsString('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));

$application = new Application();
$application->setAutoExit(false);
Expand All @@ -865,7 +865,7 @@ public function testRenderAnonymousException()
$tester = new ApplicationTester($application);

$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()
Expand All @@ -879,7 +879,7 @@ public function testRenderExceptionStackTraceContainsRootException()
$tester = new ApplicationTester($application);

$tester->run(['command' => 'foo'], ['decorated' => false]);
$this->assertContains('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
$this->assertStringContainsString('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));

$application = new Application();
$application->setAutoExit(false);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testDebug()
$handler->sendPhpResponse(new \RuntimeException($htmlWithXss));
$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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public function getFunctions()
$dump = new PhpDumper($container);
$dumped = $dump->dump();

$this->assertContains('strtolower("foobar")', $dumped);
$this->assertStringContainsString('strtolower("foobar")', $dumped);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testDebugDateTimeType()
$tester->execute(['class' => 'DateTime'], ['decorated' => false, 'interactive' => false]);

$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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testConstraint(): void
try {
$constraint->evaluate(new Response());
} 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testConstraint(): void
try {
$constraint->evaluate(new Response('', 404));
} 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testConstraint(): void
try {
$constraint->evaluate(new Response('', 404));
} 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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function testHandleWhenTheControllerDoesNotReturnAResponse()

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function testLdapRenameWithoutRemovingOldRdn()
$newEntry = $result[0];
$originalCN = $entry->getAttribute('cn')[0];

$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
$this->assertStringContainsString($originalCN, $newEntry->getAttribute('cn'));

$entryManager->rename($newEntry, 'cn='.$originalCN);

Expand Down Expand Up @@ -357,6 +357,6 @@ public function testLdapMove()

$result = $this->executeSearchQuery(1);
$movedEntry = $result[0];
$this->assertContains('ou=Ldap', $movedEntry->getDn());
$this->assertStringContainsString('ou=Ldap', $movedEntry->getDn());
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mailer/Tests/TransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function testFromDsnAmazonSes()
$this->assertInstanceOf(Amazon\Smtp\SesTransport::class, $transport);
$this->assertEquals('u$er', $transport->getUsername());
$this->assertEquals('pa$s', $transport->getPassword());
$this->assertContains('.sun.', $transport->getStream()->getHost());
$this->assertStringContainsString('.sun.', $transport->getStream()->getHost());
$this->assertProperties($transport, $dispatcher, $logger);

$client = $this->createMock(HttpClientInterface::class);
Expand Down