Skip to content

Commit 3a0994c

Browse files
committed
[Readme] Using the extension with Behat and Slim.
1 parent 166d2f8 commit 3a0994c

File tree

1 file changed

+72
-3
lines changed

1 file changed

+72
-3
lines changed

README.md

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,75 @@
1-
# A Behat extension for Slim 3
1+
# A Behat 3 extension for Slim 3
22

3-
Based on the [Behat Laravel Extension](https://github.com/laracasts/Behat-Laravel-Extension)
3+
### This extension was written based on the [Behat Laravel Extension](https://github.com/laracasts/Behat-Laravel-Extension)
44

5-
*Note* This is an experimental version.
5+
## Can install it with composer through packagist
6+
7+
```
8+
composer install pavlakis/slim-behat-extension
9+
```
10+
11+
## On your behat.yml file add the extension within the _extensions_ section
12+
13+
```
14+
Pavlakis\Slim\Behat: ~
15+
```
16+
17+
The above is the minimum setup as long as you are using [Akrabat's Slim 3 Skeleton](https://github.com/akrabat/slim3-skeleton) with the default location for `settings.php` at `app/settings.php`
18+
19+
Alternatively, pass the location of the config_file
20+
21+
```
22+
config_file: ../../app/configs/settings_test.php
23+
```
24+
25+
Apart from the config (settings.php) all other parameters are optional, however you can also pass:
26+
27+
```
28+
config_file: ../../app/configs/settings_test.php
29+
dependencies_file: ../../app/dependencies.php
30+
middleware_file: ../../middleware.php
31+
routes_file: ../../routes.php
32+
```
33+
34+
## In your *FeatureContext* file
35+
36+
* Include the _KernelAwareContext_ interface
37+
* Include the _Pavlakis\Slim\Behat\Context\App_ trait
38+
* Access the Slim 3 app using `$this->app`
39+
40+
### Feature Context example using Mink
41+
42+
```php
43+
use Behat\Behat\Context\Context;
44+
use Behat\Behat\Context\SnippetAcceptingContext;
45+
46+
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
47+
use Behat\MinkExtension\Context\MinkContext;
48+
use Pavlakis\Slim\Behat\Context\App;
49+
use Pavlakis\Slim\Behat\Context\KernelAwareContext;
50+
51+
/**
52+
* Defines application features from the specific context.
53+
*/
54+
class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext, KernelAwareContext
55+
{
56+
use App;
57+
58+
/**
59+
* Initializes context.
60+
*
61+
* Every scenario gets its own context instance.
62+
* You can also pass arbitrary arguments to the
63+
* context constructor through behat.yml.
64+
*/
65+
public function __construct()
66+
{
67+
}
68+
}
69+
70+
```
71+
72+
### Accessing your dependencies
73+
74+
`$this->app->getContainer()->get('db')`
675

0 commit comments

Comments
 (0)