Skip to content

Commit 9baa5ec

Browse files
authored
Merge pull request #1 from MacPaw/feat/addReadMe
feat: change automatically release settings
2 parents 1a21dd5 + 836df3d commit 9baa5ec

File tree

2 files changed

+98
-2
lines changed

2 files changed

+98
-2
lines changed

.releaserc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"branches": [
3-
"master"
3+
"main"
44
],
55
"plugins": [
66
"@semantic-release/commit-analyzer",

README.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,97 @@
1-
# BehatHttpMockContext
1+
Behat HTTP Mock Context
2+
=================================
3+
4+
| Version | Build Status | Code Coverage |
5+
|:---------:|:-------------:|:-----:|
6+
| `main` | [![CI][main Build Status Image]][main Build Status] | [![Coverage Status][main Code Coverage Image]][main Code Coverage] |
7+
| `develop` | [![CI][develop Build Status Image]][develop Build Status] | [![Coverage Status][develop Code Coverage Image]][develop Code Coverage] |
8+
9+
Installation
10+
============
11+
12+
Step 1: Install Context
13+
----------------------------------
14+
Open a command console, enter your project directory and execute:
15+
16+
```console
17+
$ composer require --dev macpaw/behat-http-mock-context
18+
```
19+
20+
Step 2: Update Container config to load Context
21+
----------------------------------
22+
In the `config/services_test.yaml` file of your project:
23+
24+
```yaml
25+
BehatHttpMockContext\:
26+
resource: '../vendor/macpaw/behat-http-mock-context/src/*'
27+
arguments:
28+
- '@test.service_container'
29+
30+
BehatHttpMockContext\Collection\ExtendedMockHttpClientCollection:
31+
arguments:
32+
- !tagged_iterator mock.http_client
33+
```
34+
35+
Step 2: Mock http client
36+
=============
37+
Example you have http client in `config/services.yaml`
38+
```yaml
39+
oauth_http_client:
40+
class: Symfony\Contracts\HttpClient\HttpClientInterface
41+
factory: ['Symfony\Component\HttpClient\HttpClient', createForBaseUri]
42+
arguments:
43+
- '%env(OAUTH_URL)%'
44+
```
45+
46+
Now you need mock this client in `config/services_test.yaml`
47+
48+
```yaml
49+
oauth_http_client:
50+
class: ExtendedMockHttpClient\ExtendedMockHttpClient
51+
arguments:
52+
- '%env(OAUTH_URL)%'
53+
tags: ['mock.http_client']
54+
...
55+
```
56+
57+
Now we ready add build mock collection
58+
```yaml
59+
BehatHttpMockContext\Collection\ExtendedMockHttpClientCollection:
60+
arguments:
61+
- !tagged_iterator mock.http_client
62+
...
63+
```
64+
65+
Step 4: Configure Behat
66+
=============
67+
Go to `behat.yml`
68+
69+
```yaml
70+
...
71+
contexts:
72+
- BehatHttpMockContext\Context\MockContext
73+
...
74+
```
75+
76+
Step 4: How to use:
77+
=============
78+
```
79+
Given I mock "oauth_http_client" HTTP client next response status code should be 200 with body:
80+
"""
81+
{
82+
"success": true,
83+
"response": {
84+
"user_id": 234
85+
}
86+
}
87+
"""
88+
```
89+
90+
[main Build Status]: https://github.com/macpaw/BehatHttpMockContext/actions?query=workflow%3ACI+branch%3Amain
91+
[main Build Status Image]: https://github.com/macpaw/BehatHttpMockContext/workflows/CI/badge.svg?branch=main
92+
[develop Build Status]: https://github.com/macpaw/BehatHttpMockContext/actions?query=workflow%3ACI+branch%3Adevelop
93+
[develop Build Status Image]: https://github.com/macpaw/BehatHttpMockContext/workflows/CI/badge.svg?branch=develop
94+
[main Code Coverage]: https://codecov.io/gh/macpaw/BehatHttpMockContext/branch/main
95+
[main Code Coverage Image]: https://img.shields.io/codecov/c/github/macpaw/BehatHttpMockContext/main?logo=codecov
96+
[develop Code Coverage]: https://codecov.io/gh/macpaw/BehatHttpMockContext/branch/develop
97+
[develop Code Coverage Image]: https://img.shields.io/codecov/c/github/macpaw/BehatHttpMockContext/develop?logo=codecov

0 commit comments

Comments
 (0)