Skip to content
This repository was archived by the owner on Feb 5, 2021. It is now read-only.

Commit a94e07a

Browse files
authored
Merge pull request #2 from pamil/docs
Finish "Usage" section in readme
2 parents ff2c2b8 + cc8c21d commit a94e07a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

README.md

+48
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Allows to declare and use contexts services in scenario scoped container.
1313
2. Enable and configure context service extension in your Behat configuration:
1414

1515
```yaml
16+
# behat.yml
1617
default:
1718
# ...
1819
extensions:
@@ -22,3 +23,50 @@ Allows to declare and use contexts services in scenario scoped container.
2223
- "features/bootstrap/config/services.yml"
2324
- "features/bootstrap/config/services.php"
2425
```
26+
27+
3. Inside one of those files passed to configuration above, create a service tagged with `fob.context_service`.
28+
29+
```xml
30+
<!-- features/bootstrap/config/services.xml -->
31+
<?xml version="1.0" encoding="UTF-8" ?>
32+
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services">
33+
<services>
34+
<service id="acme.my_context" class="Acme\MyContext">
35+
<tag name="fob.context_service" />
36+
</service>
37+
</services>
38+
</container>
39+
```
40+
41+
```yaml
42+
# features/bootstrap/config/services.yml
43+
services:
44+
acme.my_context:
45+
class: Acme\MyContext
46+
tags:
47+
- { name: fob.context_service }
48+
```
49+
50+
```php
51+
// features/bootstrap/config/services.php
52+
53+
use Symfony\Component\DependencyInjection\Definition;
54+
55+
$definition = new Definition(\Acme\MyContext::class);
56+
$definition->addTag('fob.context_service');
57+
$container->setDefinition('acme.my_context', $definition);
58+
```
59+
60+
4. Configure your suite to use `acme.my_context` context service (note **contexts_services** key instead of **contexts**):
61+
62+
```yaml
63+
# behat.yml
64+
default:
65+
# ...
66+
suites:
67+
default:
68+
contexts_services:
69+
- acme.my_context
70+
```
71+
72+
5. Have fun with your contexts defined in DI container as services! :tada:

0 commit comments

Comments
 (0)