Skip to content

Commit

Permalink
Update syntax in readme (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm authored Aug 20, 2021
1 parent 0694254 commit 2b41327
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You need to tell the bundle what services you want to mock. That could be done w
the "`happyr_service_mock`" service tag or by defining a list of service ids:

<details>
<summary>PHP config</summary>
<summary>PHP config (Symfony 5.3)</summary>
<br>

```php
Expand Down Expand Up @@ -87,7 +87,9 @@ class MyTest extends WebTestCase
{
// ...

$apiClient = self::$container->get(AcmeApiClient::class);
$apiClient = self::getContainer()->get(AcmeApiClient::class);
// On Symfony < 5.3
// $apiClient = self::$container->get(AcmeApiClient::class);

// For all calls to $apiClient->show()
ServiceMock::all($apiClient, 'show', function ($id) {
Expand All @@ -106,7 +108,7 @@ class MyTest extends WebTestCase
});

$mock = // create a PHPUnit mock or any other mock you want.
ServiceMock::swap(self::$container->get(OtherService::class), $mock);
ServiceMock::swap(self::getContainer()->get(OtherService::class), $mock);

// ...
self::$client->request(...);
Expand Down

0 comments on commit 2b41327

Please sign in to comment.