Completed
Push — master ( 658d5b...53259c )
by John
02:58
created

SwaggerDocumentTest::getOperationDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the KleijnWeb\SwaggerBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\SwaggerBundle\Tests\Document;
10
11
use KleijnWeb\SwaggerBundle\Document\DocumentRepository;
12
use KleijnWeb\SwaggerBundle\Document\SwaggerDocument;
13
14
/**
15
 * @author John Kleijn <[email protected]>
16
 */
17
class SwaggerDocumentTest extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @test
21
     */
22 View Code Duplication
    public function canGetPathDefinitions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        $actual = self::getPetStoreDocument()->getPathDefinitions();
25
        $this->assertInternalType('object', $actual);
26
27
        // Check a few attributes
28
        $this->assertObjectHasAttribute('/pet', $actual);
29
        $this->assertObjectHasAttribute('/pet/findByStatus', $actual);
30
        $this->assertObjectHasAttribute('/store/inventory', $actual);
31
        $this->assertObjectHasAttribute('/user', $actual);
32
    }
33
34
    /**
35
     * @test
36
     */
37 View Code Duplication
    public function getOperationDefinition()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $actual = self::getPetStoreDocument()->getOperationDefinition('/store/inventory', 'get');
0 ignored issues
show
Deprecated Code introduced by
The method KleijnWeb\SwaggerBundle\...etOperationDefinition() has been deprecated.

This method has been deprecated.

Loading history...
40
        $this->assertInternalType('object', $actual);
41
42
        // Check a few attributes
43
        $this->assertObjectHasAttribute('parameters', $actual);
44
        $this->assertObjectHasAttribute('responses', $actual);
45
        $this->assertObjectHasAttribute('security', $actual);
46
    }
47
48
    /**
49
     * @test
50
     */
51
    public function getOperationDefinitionHttpMethodIsCaseInsensitive()
52
    {
53
        self::getPetStoreDocument()->getOperationDefinition('/store/inventory', 'GET');
0 ignored issues
show
Deprecated Code introduced by
The method KleijnWeb\SwaggerBundle\...etOperationDefinition() has been deprecated.

This method has been deprecated.

Loading history...
54
    }
55
56
57
    /**
58
     * @expectedException \InvalidArgumentException
59
     * @test
60
     */
61
    public function getOperationDefinitionWillFailOnUnknownHttpMethod()
62
    {
63
        self::getPetStoreDocument()->getOperationDefinition('/store/inventory', 'post');
0 ignored issues
show
Deprecated Code introduced by
The method KleijnWeb\SwaggerBundle\...etOperationDefinition() has been deprecated.

This method has been deprecated.

Loading history...
64
    }
65
66
    /**
67
     * @expectedException \InvalidArgumentException
68
     * @test
69
     */
70
    public function getOperationDefinitionWillFailOnUnknownPath()
71
    {
72
        self::getPetStoreDocument()->getOperationDefinition('/this/is/total/bogus', 'post');
0 ignored issues
show
Deprecated Code introduced by
The method KleijnWeb\SwaggerBundle\...etOperationDefinition() has been deprecated.

This method has been deprecated.

Loading history...
73
    }
74
75
    /**
76
     * @return SwaggerDocument
77
     */
78
    public static function getPetStoreDocument()
79
    {
80
        $repository = new DocumentRepository('src/Tests/Functional/PetStore');
81
82
        return $repository->get('app/swagger/petstore.yml');
83
    }
84
}
85