GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

shouldCreateParametersFromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/**
3
 * ParameterParserTest
4
 *
5
 * @author Piotr Olaszewski <[email protected]>
6
 */
7
use WSDL\Parser\ParameterParser;
8
9
class ParameterParserTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
    /**
12
     * @test
13
     */
14
    public function shouldCreateParametersFromArray()
15
    {
16
        //given
17
        $arrayOfParameters = array(
18
            'int $a',
19
            'string $b',
20
            'object $object1 @string=name @int=id'
21
        );
22
23
        //when
24
        $create = ParameterParser::create($arrayOfParameters, '');
25
26
        //then
27
        $this->assertCount(3, $create);
28
    }
29
30
    /**
31
     * @test
32
     */
33 View Code Duplication
    public function shouldParseSimpleType()
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...
34
    {
35
        //given
36
        $parameter = 'int $a';
37
        $parser = new ParameterParser($parameter);
38
39
        //when
40
        $parser->parse();
41
42
        //then
43
        $this->assertEquals('a', $parser->getName());
44
        $this->assertEquals('int', $parser->getType());
45
        $this->assertFalse($parser->isComplex());
46
    }
47
48
    /**
49
     * @test
50
     * @expectedException \WSDL\Parser\ParameterParserException
51
     */
52
    public function shouldThrowExceptionIfNotComplexType()
53
    {
54
        //given
55
        $parameter = 'int $a';
56
        $parser = new ParameterParser($parameter);
57
58
        //when
59
        $parser->complexTypes();
60
    }
61
62
    /**
63
     * @test
64
     */
65 View Code Duplication
    public function shouldParseComplexType()
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...
66
    {
67
        //given
68
        $parameter = 'object $object1 @string=$name @int=$id';
69
        $parser = new ParameterParser($parameter);
70
71
        //when
72
        $parser->parse();
73
74
        //then
75
        $this->assertEquals('object1', $parser->getName());
76
        $this->assertEquals('object', $parser->getType());
77
        $this->assertTrue($parser->isComplex());
78
        $this->assertCount(2, $parser->complexTypes());
79
    }
80
81
    /**
82
     * @test
83
     */
84 View Code Duplication
    public function shouldParseObjectWrapper()
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...
85
    {
86
        //given
87
        $parameter = 'wrapper $user @className=\Mocks\MockUserWrapper';
88
        $parser = new ParameterParser($parameter);
89
90
        //when
91
        $parser->parse();
92
93
        //then
94
        $this->assertEquals('user', $parser->getName());
95
        $this->assertEquals('MocksMockUserWrapper', $parser->getType());
96
    }
97
98
    /**
99
     * @test
100
     */
101 View Code Duplication
    public function shouldParseObjectWrapperArray()
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...
102
    {
103
        //given
104
        $parameter = 'wrapper[] $users @className=\Mocks\MockUserWrapper';
105
        $parser = new ParameterParser($parameter);
106
107
        //when
108
        $parser->parse();
109
110
        //then
111
        $this->assertEquals('users', $parser->getName());
112
        $this->assertEquals('MocksMockUserWrapper', $parser->getType());
113
    }
114
115
    /**
116
     * @test
117
     */
118
    public function shouldParseParams()
119
    {
120
        $array = array(
121
            'int $simple1',
122
            'int[] $simple2',
123
            'object $object1 @string=$name1 @int=$id',
124
            'object $object2 @(wrapper $wr1 @className=\Mocks\MockUserWrapper) @int=$id',
125
            'object $object3 @string[]=$name2 @int=$id',
126
            'object $object4 @(wrapper[] $wr2 @className=\Mocks\MockUserWrapper) @int=$id',
127
            'object[] $object5 @string=$name3 @int=$id',
128
            'object[] $object6 @string[]=$name4 @int=$id',
129
            'object[] $object7 @(wrapper $wr3 @className=\Mocks\MockUserWrapper) @int=$id',
130
            'object[] $object8 @(wrapper[] $wr4 @className=\Mocks\MockUserWrapper) @int=$id',
131
            'wrapper $wrapp1 @className=\Mocks\MockUserWrapper',
132
            'wrapper[] $wrapp2 @className=\Mocks\MockUserWrapper',
133
        );
134
        ParameterParser::create($array, 'sampleMethod');
135
    }
136
}
137