Passed
Pull Request — master (#9)
by Rafael
03:29
created

ResponseContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 22
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assertResponseIsOk() 0 3 1
A assertResponseStatus() 0 3 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Behat\Context;
12
13
use Behat\Behat\Context\Context;
14
use PHPUnit\Framework\Assert;
15
use Symfony\Component\HttpFoundation\Response;
16
use Ynlo\GraphQLBundle\Behat\Client\ClientAwareInterface;
17
use Ynlo\GraphQLBundle\Behat\Client\ClientAwareTrait;
18
19
/**
20
 * Context to work with latest response
21
 */
22
final class ResponseContext implements Context, ClientAwareInterface
23
{
24
    use ClientAwareTrait;
25
26
    /**
27
     * Checks, that current response status is equal to specified
28
     * Example: Then the response status code should be 200
29
     * Example: And the response status code should be 400
30
     *
31
     * @Then /^the response status code should be (?P<code>\d+)$/
32
     */
33
    public function assertResponseStatus($code)
34
    {
35
        Assert::assertEquals($this->client->getResponse()->getStatusCode(), $code);
36
    }
37
38
    /**
39
     * @Then the response is OK
40
     */
41
    public function assertResponseIsOk()
42
    {
43
        $this->assertResponseStatus(Response::HTTP_OK);
44
    }
45
}