Skip to content

Commit

Permalink
Merge 283beb9 into d005f7c
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed May 10, 2021
2 parents d005f7c + 283beb9 commit bf71f93
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/Bridge/Symfony/Bundle/Test/Client.php
Expand Up @@ -244,4 +244,16 @@ private static function extractHeaders(array $options): array

return $headers;
}

/**
* {@inheritdoc}
* TODO: Delete this when we can use symfony/http-client:^5.3.
*/
public function withOptions(array $options): self
{
$clone = clone $this;
$clone->defaultOptions = self::mergeDefaultOptions($options, $this->defaultOptions);

return $clone;
}
}
17 changes: 16 additions & 1 deletion tests/Bridge/Symfony/Bundle/Test/ApiTestCaseTest.php
Expand Up @@ -22,16 +22,31 @@
use Doctrine\ORM\Tools\SchemaTool;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Runner\Version;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\HttpClient\CurlHttpClient;

class ApiTestCaseTest extends ApiTestCase
{
use ExpectDeprecationTrait;

/**
* TODO: remove the deprecation HttpClientInterface::withOptions will be available in symfony:^5.3.
*
* @group legacy
*/
public function testAssertJsonContains(): void
{
if (version_compare(Version::id(), '8.0.0', '<')) {
$this->markTestSkipped('Requires PHPUnit 8');
}

self::createClient()->request('GET', '/');
$client = self::createClient();

if (!method_exists(CurlHttpClient::class, 'withOptions')) {
$this->expectDeprecation(sprintf('Class %s should implement method "Symfony\Contracts\HttpClient\HttpClientInterface::withOptions(array $options)": Returns a new instance of the client with new default options.', get_class($client)));
}

$client->request('GET', '/');
$this->assertJsonContains(['@context' => '/contexts/Entrypoint']);
}

Expand Down

0 comments on commit bf71f93

Please sign in to comment.