Skip to content

Commit e36dd28

Browse files
committed
Made a start on the README usage
1 parent 1bc2705 commit e36dd28

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# Laravel Hooks for Dredd API Testing Framework
22
This package contains a PHP Dredd hook handler which provides a bridge between the [Dredd API Testing Framework](http://dredd.readthedocs.org/en/latest/)
33
and PHP environment to ease implementation of testing hooks provided by [Dredd](http://dredd.readthedocs.org/en/latest/). Most of the heavy lifting is provided by the [ddelnano/dredd-hooks-php](https://github.com/ddelnano/dredd-hooks-php) package.
4-
5-
## Dredd Setup
4+
5+
## Installation
6+
### Composer
7+
8+
Laravel Hooks for Dredd should be installed via composer, we recommend you put this in your require-dev section.
9+
10+
```bash
11+
composer require ddelnano/dredd-hooks-laravel --dev
12+
```
13+
14+
### Dredd Setup
615
In order to inject environment variables and use the full power of Larvel Dredd Hooks, you need to add the following to your `dredd.yml` file (or put in your console arguments).
716

817
```yml
@@ -12,4 +21,34 @@ hookfiles: 'tests/dredd/Kernel.php'
1221
language: 'vendor/bin/dredd-hooks-laravel'
1322
server: 'php -S 127.0.0.1:3000 ./vendor/netsells/dredd-hooks-laravel/server.php -t public/'
1423
endpoint: 'http://127.0.0.1:3000'
24+
```
25+
26+
## Usage
27+
28+
The package requires you to make a single file (named in the `hookfiles` part of dredd.yml above). This should have at least the `handle` method.
29+
30+
```php
31+
<?php
32+
33+
namespace Tests\Dredd;
34+
35+
use Netsells\Dredd\Hook;
36+
use Netsells\Dredd\Transaction;
37+
use Illuminate\Support\Facades\Artisan;
38+
use Netsells\Dredd\Kernel as DreddKernel;
39+
40+
class Kernel extends DreddKernel
41+
{
42+
public function handle(Hook $hook)
43+
{
44+
$this->beforeEach(function (Transaction &$transaction) {
45+
Artisan::call('migrate:fresh');
46+
Artisan::call('passport:install');
47+
48+
Artisan::call('db:seed');
49+
});
50+
51+
$hook->group('Posts', Hooks\Posts::class);
52+
}
53+
}
1554
```

0 commit comments

Comments
 (0)