Completed
Push — master ( 215d99...92be6e )
by Tristan
10:33
created

SwaggerContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 30
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A theResponseMatchSwagger() 0 8 1
1
<?php
2
3
namespace Nicofuma\SwaggerBundle\Tests\Behat\Context;
4
5
use BootstrapBundle\Tests\Behat\Context\Traits\ClientContextTrait;
6
use FR3D\SwaggerAssertions\PhpUnit\SymfonyAssertsTrait;
7
use Sanpi\Behatch\Context\BaseContext;
8
use Nicofuma\SwaggerBundle\Validator\ValidatorMap;
9
10
class SwaggerContext extends BaseContext
11
{
12
    use ClientContextTrait;
13
    use SymfonyAssertsTrait;
14
15
    /** @var ValidatorMap */
16
    private $map;
17
18
    public function __construct(ValidatorMap $map)
19
    {
20
        $this->map = $map;
21
    }
22
23
    /**
24
     * This method match the response against its Swagger definition.
25
     *
26
     * @throws \Behat\Mink\Exception\ExpectationException
27
     * @throws \Exception
28
     *
29
     * @Then the response should match the Swagger definition
30
     */
31
    public function theResponseMatchSwagger()
32
    {
33
        $response = $this->getResponse();
34
        $request = $this->getRequest();
35
        $schemaManager = $this->map->getValidator($request)->getSchemaManager();
36
37
        $this->assertResponseMatch($response, $schemaManager, $request->getPathInfo(), $request->getMethod());
38
    }
39
}
40