1- Behat Api Context Bundle
2- =================================
1+ # Behat Api Context Bundle
32
43| Version | Build Status | Code Coverage |
54| :---------:| :-------------:| :-----:|
6- | ` master ` | [ ![ CI] [ master Build Status Image ]] [ master Build Status ] | [ ![ Coverage Status] [ master Code Coverage Image ]] [ master Code Coverage ] |
7- | ` develop ` | [ ![ CI] [ develop Build Status Image ]] [ develop Build Status ] | [ ![ Coverage Status] [ develop Code Coverage Image ]] [ develop Code Coverage ] |
5+ | ` master ` | [ ![ CI] [ master Build Status Image ]] [ master Build Status ] | [ ![ Coverage Status] [ master Code Coverage Image ]] [ master Code Coverage ] |
6+ | ` develop ` | [ ![ CI] [ develop Build Status Image ]] [ develop Build Status ] | [ ![ Coverage Status] [ develop Code Coverage Image ]] [ develop Code Coverage ] |
87
9- Installation
10- ============
8+ ## Installation
9+
10+ ### Step 1: Download the Bundle
1111
12- Step 1: Download the Bundle
13- ----------------------------------
1412Open a command console, enter your project directory and execute:
1513
16- ### Applications that use Symfony Flex [ in progress] ( https://github.com/MacPaw/BehatRedisContext/issues/2 )
14+ #### Applications that use Symfony Flex [ in progress] ( https://github.com/MacPaw/BehatRedisContext/issues/2 )
1715
18- ``` console
19- $ composer require --dev macpaw/behat-api-context
16+ ``` bash
17+ composer require --dev macpaw/behat-api-context
2018```
2119
22- ### Applications that don't use Symfony Flex
20+ #### Applications that don't use Symfony Flex
2321
24- Open a command console, enter your project directory and execute the
25- following command to download the latest stable version of this bundle:
22+ Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
2623
27- ``` console
28- $ composer require --dev macpaw/behat-api-context
24+ ``` bash
25+ composer require --dev macpaw/behat-api-context
2926```
3027
3128This command requires you to have Composer installed globally, as explained
@@ -57,9 +54,11 @@ class AppKernel extends Kernel
5754}
5855```
5956
60- Step 2: Configure Behat
61- =============
62- Go to ` behat.yml `
57+ ---
58+
59+ ## Step 2: Configure Behat
60+
61+ Go to ` behat.yml ` :
6362
6463``` yaml
6564# ...
@@ -68,45 +67,92 @@ Go to `behat.yml`
6867# ...
6968```
7069
71- If you want use orm context add to ` behat.yml `
70+ ### Optional: Enable ORMContext
71+
72+ If you want to use ` ORMContext ` , you need to have ` doctrine/orm ` installed:
73+
74+ ``` bash
75+ composer require --dev doctrine/orm
76+ ```
77+
78+ Then, update your ` behat.yml ` :
79+
7280``` yaml
7381# ...
7482 contexts :
7583 - BehatApiContext\Context\ORMContext
7684# ...
7785```
7886
79- Usage
80- =============
87+ ---
88+
89+ ## Configuration
90+
91+ By default, the bundle has the following configuration:
92+
93+ ``` yaml
94+ behat_api_context :
95+ kernel_reset_managers : []
96+ use_orm_context : true
97+ ` ` `
98+
99+ | ORM Installed | Default ` use_orm_context` |
100+ |:-------------:|:-------------------------:|
101+ | Yes | `true` |
102+ | No | `false` |
103+
104+ You can override it manually in your `config/packages/test/behat_api_context.yaml` :
81105
82- Runnable request parameters
83- ----------------------------------
84- Main use case when tests need to use current date.
85- Instead of static data in some ` testCaseName.feature ` , like this:
86- ``` feature
106+ ` ` ` yaml
107+ behat_api_context:
108+ use_orm_context: false
109+ ` ` `
110+
111+ or
112+
113+ ` ` ` yaml
114+ behat_api_context:
115+ use_orm_context: true
116+ ` ` `
117+
118+ depending on your needs.
119+
120+ ---
121+
122+ # Usage
123+
124+ # ## Runnable request parameters
125+
126+ Main use case when tests need to use the current date.
127+ Instead of static data in some `.feature` file like this :
128+
129+ ` ` ` gherkin
87130"""
88131{
89132 "dateTo": 1680360081,
90- "dateFrom": 1680532881,
133+ "dateFrom": 1680532881
91134}
92135"""
93136` ` `
94- Can use, for example:
95- ``` feature
137+
138+ You can use dynamic expressions :
139+
140+ ` ` ` gherkin
96141"""
97142{
98143 "dateTo": "<(new DateTimeImmutable())->add(new DateInterval('P6D'))->getTimeStamp()>",
99- "dateFrom": "<(new DateTimeImmutable())->add(new DateInterval('P2D'))->getTimeStamp()>",
144+ "dateFrom": "<(new DateTimeImmutable())->add(new DateInterval('P2D'))->getTimeStamp()>"
100145}
101146"""
102147` ` `
103148
104- #### To accomplish this, several conditions must be met:
105- - Runnable code must be a string and placed in ` <> `
106- - Should not add ` return ` keyword at the beginning, otherwise will get RuntimeException
107- - Should not add ` ; ` keyword at the end, otherwise will get RuntimeException
108- - Should not use the code that returns ` null ` , otherwise will get RuntimeException
149+ # ### To achieve this, several conditions must be met:
150+ - Runnable code must be a string and placed inside `<>`.
151+ - Do not add `return` keyword at the beginning, otherwise a `RuntimeException` will be thrown.
152+ - Do not add `;` at the end of the expression , otherwise a `RuntimeException` will be thrown.
153+ - Avoid code that returns `null`, otherwise a `RuntimeException` will be thrown.
109154
155+ ---
110156
111157[master Build Status] : https://github.com/macpaw/behat-api-context/actions?query=workflow%3ACI+branch%3Amaster
112158[master Build Status Image] : https://github.com/macpaw/behat-api-context/workflows/CI/badge.svg?branch=master
0 commit comments