8000 minor #13511 [Testing] Change deprecated assertContains to assertStri… · symfony/symfony-docs@0147fe6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0147fe6

Browse files
committed
minor #13511 [Testing] Change deprecated assertContains to assertStringContainsString (Wojciech Kania)
This PR was merged into the 5.0 branch. Discussion ---------- [Testing] Change deprecated assertContains to assertStringContainsString Symfony 5 requires PHP 7.2. PHPUnit Bridge for this version by default use [PHPUnit 8.3](https://symfony.com/doc/current/components/phpunit_bridge.html#modified-phpunit-script). The assertContains is [deprecated](sebastianbergmann/phpunit#3425) and in PHPUnit 9 throws an error. Commits ------- e4d8c27 [Testing] Change deprecated assertContains to assertStringContainsString
2 parents 1993834 + e4d8c27 commit 0147fe6

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

console.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ console::
356356

357357
// the output of the command in the console
358358
$output = $commandTester->getDisplay();
359-
$this->assertContains('Username: Wouter', $output);
359+
$this->assertStringContainsString('Username: Wouter', $output);
360360

361361
// ...
362362
}

create_framework/unit_testing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ resolver. Modify the framework to make use of them::
4949
namespace Simplex;
5050

5151
// ...
52-
52+
5353
use Calendar\Controller\LeapYearController;
5454
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
5555
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
@@ -183,7 +183,7 @@ Response::
183183
$response = $framework->handle(new Request());
184184

185185
$this->assertEquals(200, $response->getStatusCode());
186-
$this->assertContains('Yep, this is a leap year!', $response->getContent());
186+
$this->assertStringContainsString('Yep, this is a leap year!', $response->getContent());
187187
}
188188

189189
In this test, we simulate a route that matches and returns a simple

testing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ Or test against the response content directly if you just want to assert that
270270
the content contains some text or in case that the response is not an XML/HTML
271271
document::
272272

273-
$this->assertContains(
273+
$this->assertStringContainsString(
274274
'Hello World',
275275
$client->getResponse()->getContent()
276276
);
@@ -316,7 +316,7 @@ document::
316316
);
317317

318318
// asserts that the response content contains a string
319-
$this->assertContains('foo', $client->getResponse()->getContent());
319+
$this->assertStringContainsString('foo', $client->getResponse()->getContent());
320320
// ...or matches a regex
321321
$this->assertRegExp('/foo(bar)?/', $client->getResponse()->getContent());
322322

0 commit comments

Comments
 (0)
0