This repository was archived by the owner on Feb 5, 2021. It is now read-only.
File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ Allows to declare and use contexts services in scenario scoped container.
13
13
2. Enable and configure context service extension in your Behat configuration:
14
14
15
15
` ` ` yaml
16
+ # behat.yml
16
17
default:
17
18
# ...
18
19
extensions:
@@ -22,3 +23,50 @@ Allows to declare and use contexts services in scenario scoped container.
22
23
- " features/bootstrap/config/services.yml"
23
24
- " features/bootstrap/config/services.php"
24
25
` ` `
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\M yContext
46
+ tags:
47
+ - { name: fob.context_service }
48
+ ` ` `
49
+
50
+ ` ` ` php
51
+ // features/bootstrap/config/services.php
52
+
53
+ use Symfony\C omponent\D ependencyInjection\D efinition;
54
+
55
+ $definition = new Definition(\A cme\M yContext::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:
You can’t perform that action at this time.
0 commit comments