Skip to content

Commit

Permalink
minor #13511 [Testing] Change deprecated assertContains to assertStri…
Browse files Browse the repository at this point in the history
…ngContainsString (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
  • Loading branch information
javiereguiluz committed Apr 9, 2020
2 parents 1993834 + e4d8c27 commit 0147fe6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion console.rst
Expand Up @@ -356,7 +356,7 @@ console::

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

// ...
}
Expand Down
4 changes: 2 additions & 2 deletions create_framework/unit_testing.rst
Expand Up @@ -49,7 +49,7 @@ resolver. Modify the framework to make use of them::
namespace Simplex;

// ...

use Calendar\Controller\LeapYearController;
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
Expand Down Expand Up @@ -183,7 +183,7 @@ Response::
$response = $framework->handle(new Request());

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

In this test, we simulate a route that matches and returns a simple
Expand Down
4 changes: 2 additions & 2 deletions testing.rst
Expand Up @@ -270,7 +270,7 @@ Or test against the response content directly if you just want to assert that
the content contains some text or in case that the response is not an XML/HTML
document::

$this->assertContains(
$this->assertStringContainsString(
'Hello World',
$client->getResponse()->getContent()
);
Expand Down Expand Up @@ -316,7 +316,7 @@ document::
);

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

Expand Down

0 comments on commit 0147fe6

Please sign in to comment.