Skip to content

Commit 5ad0332

Browse files
Stephan Wentzpl-github
authored andcommitted
ci: Split READMEs, add missing docs for CREATE_SNAPSHOT env variable
1 parent 0e7fb7b commit 5ad0332

File tree

7 files changed

+392
-359
lines changed

7 files changed

+392
-359
lines changed

README.console-trait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# brainbits Functional Test Helpers
2+
3+
## Console Trait
4+
5+
todo...

README.http-client-trait.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# brainbits Functional Test Helpers
2+
3+
## HTTP Client Trait
4+
5+
To use the mock http client, configure the `MockRequestBuilderCollection` as `mock_response_factory` in the framework configuration section.
6+
7+
Example symfony config:
8+
9+
```yaml
10+
# config/packages/http_client.yaml
11+
when@test:
12+
services:
13+
Brainbits\FunctionalTestHelpers\HttpClientMock\MockRequestBuilderCollection:
14+
arguments:
15+
- '@Brainbits\FunctionalTestHelpers\HttpClientMock\SymfonyMockResponseFactory'
16+
17+
Brainbits\FunctionalTestHelpers\HttpClientMock\SymfonyMockResponseFactory: ~
18+
```
19+
20+
```yaml
21+
# config/packages/framework.yaml
22+
when@test:
23+
framework:
24+
test: true
25+
http_client:
26+
mock_response_factory: 'Brainbits\FunctionalTestHelpers\HttpClientMock\MockRequestBuilderCollection'
27+
```
28+
29+
In your test, you can provide mock responses, which will be matched by the given mock requests.
30+
31+
```php
32+
// MyTest.php
33+
34+
public function testRequest(): void
35+
{
36+
$this->mockRequest('GET', 'http://127.0.0.1/my/endpoint')
37+
->willRespond($this->mockResponse()->json([]));
38+
39+
// ...
40+
41+
Assert::assertNotEmpty($this->callStack()->first);
42+
}
43+
44+
```

0 commit comments

Comments
 (0)