Skip to content

Commit

Permalink
Add PHP config example (#19)
Browse files Browse the repository at this point in the history
* Add PHP config example

* Syntax
  • Loading branch information
Nyholm authored Aug 20, 2021
1 parent f564b59 commit 0694254
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@ return [
You need to tell the bundle what services you want to mock. That could be done with
the "`happyr_service_mock`" service tag or by defining a list of service ids:

<details>
<summary>PHP config</summary>
<br>

```php
<?php
// config/packages/test/happyr_service_mocking.php

use Symfony\Config\HappyrServiceMockingConfig;

return static function (HappyrServiceMockingConfig $config) {
$config->services([
\App\AcmeApiClient::class
\App\Some\OtherService::class
]);
};

```

</details>
<details>
<summary>Yaml config</summary>
<br>

```yaml
# config/packages/test/happyr_service_mocking.yaml

Expand All @@ -47,6 +71,8 @@ happyr_service_mocking:
- 'App\Some\OtherService'
```
</details>
## Usage
```php
Expand Down Expand Up @@ -109,6 +135,6 @@ the Kernel is rebooted.
## Limitations

This trick will not work if you have two different PHP processes, i.e. you are running
your tests with Panther, Selenium etc.
your tests with Panther, Selenium etc.

We can also not create a proxy if your service is final.

0 comments on commit 0694254

Please sign in to comment.