TestRequestParser   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 32
ccs 19
cts 19
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B parse() 0 18 6
A supports() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the PostmanGeneratorBundle package.
5
 *
6
 * (c) Vincent Chalamon <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PostmanGeneratorBundle\RequestParser;
13
14
use PostmanGeneratorBundle\Model\Request;
15
use PostmanGeneratorBundle\Model\Test;
16
17
class TestRequestParser implements RequestParserInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 5
    public function parse(Request $request)
23
    {
24 5
        switch ($request->getMethod()) {
25 5
            case 'POST':
26 1
                $request->addTest(new Test('Successful POST request', 'responseCode.code === 201 || responseCode.code === 202'));
27 1
                $request->addTest(new Test('Content-Type is correct', 'postman.getResponseHeader("Content-Type") === "application/ld+json"'));
28 1
                break;
29 4
            case 'PUT':
30 4
            case 'PATCH':
31 4
            case 'GET':
32 3
                $request->addTest(new Test(sprintf('Successful %s request', $request->getMethod()), 'responseCode.code === 200'));
33 3
                $request->addTest(new Test('Content-Type is correct', 'postman.getResponseHeader("Content-Type") === "application/ld+json"'));
34 3
                break;
35 1
            case 'DELETE':
36 1
                $request->addTest(new Test('Successful DELETE request', 'responseCode.code === 204'));
37 1
                break;
38 5
        }
39 5
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 1
    public function supports(Request $request)
45
    {
46 1
        return true;
47
    }
48
}
49