Skip to content

Commit 43f0a5a

Browse files
authored
Merge pull request #9 from alOneh/fixes
Fix SwaggerContext and documentation
2 parents b13dd6a + c4a2c19 commit 43f0a5a

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Configuration
5454
-------------
5555

5656
```yml
57-
swagger:
57+
nicofuma_swagger:
5858
definition:
5959
pattern: '/api/v1'
6060
swagger_file: swagger/swagger.json
@@ -70,7 +70,7 @@ Configuration reference
7070

7171
```yml
7272
# Default configuration for extension with alias: "swagger"
73-
swagger:
73+
nicofuma_swagger:
7474
definitions:
7575
-
7676
pattern:
@@ -98,7 +98,7 @@ Behat integration
9898

9999
Add the following context in your behat.yml file
100100
```
101-
- SwaggerValidationBundle\Tests\Behat\Context\SwaggerContext: {map: '@swagger_validation.validator_map'}
101+
- Nicofuma\SwaggerBundle\Tests\Behat\Context\SwaggerContext: {map: '@swagger.validator_map'}
102102
```
103103
104104
Contributing

src/Tests/Behat/Context/SwaggerContext.php

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace Nicofuma\SwaggerBundle\Tests\Behat\Context;
44

5-
use BootstrapBundle\Tests\Behat\Context\Traits\ClientContextTrait;
5+
use Behat\Mink\Driver\BrowserKitDriver;
6+
use Behat\Mink\Exception\UnsupportedDriverActionException;
67
use FR3D\SwaggerAssertions\PhpUnit\SymfonyAssertsTrait;
78
use Nicofuma\SwaggerBundle\Validator\ValidatorMap;
89
use Sanpi\Behatch\Context\BaseContext;
910

1011
class SwaggerContext extends BaseContext
1112
{
12-
use ClientContextTrait;
1313
use SymfonyAssertsTrait;
1414

1515
/** @var ValidatorMap */
@@ -36,4 +36,38 @@ public function theResponseMatchSwagger()
3636

3737
$this->assertResponseMatch($response, $schemaManager, $request->getPathInfo(), $request->getMethod());
3838
}
39+
40+
/**
41+
* @return \Symfony\Component\BrowserKit\Client
42+
*
43+
* @throws UnsupportedDriverActionException
44+
*/
45+
protected function getClient()
46+
{
47+
$driver = $this->getSession()->getDriver();
48+
49+
if (!$driver instanceof BrowserKitDriver) {
50+
throw new UnsupportedDriverActionException('This step is only supported by the BrowserKitDriver, not the %s one', $driver);
51+
}
52+
53+
return $driver->getClient();
54+
}
55+
56+
/**
57+
* Get the last response.
58+
*
59+
* @return \Symfony\Component\HttpFoundation\Response
60+
*/
61+
protected function getResponse()
62+
{
63+
return $this->getClient()->getResponse();
64+
}
65+
66+
/**
67+
* @return \Symfony\Component\HttpFoundation\Request
68+
*/
69+
public function getRequest()
70+
{
71+
return $this->getClient()->getRequest();
72+
}
3973
}

0 commit comments

Comments
 (0)