Completed
Push — master ( c89193...79c6c8 )
by Kyle
11:15 queued 10s
created

getFirstPreDecrementExpressionInFunction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of PDepend.
4
 *
5
 * PHP Version 5
6
 *
7
 * Copyright (c) 2008-2017 Manuel Pichler <[email protected]>.
8
 * All rights reserved.
9
 *
10
 * Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions
12
 * are met:
13
 *
14
 *   * Redistributions of source code must retain the above copyright
15
 *     notice, this list of conditions and the following disclaimer.
16
 *
17
 *   * Redistributions in binary form must reproduce the above copyright
18
 *     notice, this list of conditions and the following disclaimer in
19
 *     the documentation and/or other materials provided with the
20
 *     distribution.
21
 *
22
 *   * Neither the name of Manuel Pichler nor the names of his
23
 *     contributors may be used to endorse or promote products derived
24
 *     from this software without specific prior written permission.
25
 *
26
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
 * POSSIBILITY OF SUCH DAMAGE.
38
 *
39
 * @copyright 2008-2017 Manuel Pichler. All rights reserved.
40
 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
41
 */
42
43
namespace PDepend\Source\AST;
44
45
/**
46
 * Test case for the {@link \PDepend\Source\AST\ASTPreDecrementExpression} class.
47
 *
48
 * @copyright 2008-2017 Manuel Pichler. All rights reserved.
49
 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
50
 *
51
 * @covers \PDepend\Source\Language\PHP\AbstractPHPParser
52
 * @covers \PDepend\Source\AST\ASTPreDecrementExpression
53
 * @group unittest
54
 */
55
class ASTPreDecrementExpressionTest extends ASTNodeTest
56
{
57
    /**
58
     * testPreDecrementExpressionOnStaticClassMember
59
     *
60
     * @return void
61
     */
62 View Code Duplication
    public function testPreDecrementExpressionOnStaticClassMember()
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...
63
    {
64
        $expr = $this->getFirstPreDecrementExpressionInFunction(__METHOD__);
65
        $this->assertGraphEquals(
66
            $expr,
67
            array(
68
                'PDepend\\Source\\AST\\ASTMemberPrimaryPrefix',
69
                'PDepend\\Source\\AST\\ASTClassOrInterfaceReference',
70
                'PDepend\\Source\\AST\\ASTPropertyPostfix',
71
                'PDepend\\Source\\AST\\ASTVariable'
72
            )
73
        );
74
    }
75
76
    /**
77
     * testPreDecrementExpressionOnSelfClassMember
78
     *
79
     * @return void
80
     */
81 View Code Duplication
    public function testPreDecrementExpressionOnSelfClassMember()
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...
82
    {
83
        $expr = $this->getFirstPreDecrementExpressionInClass(__METHOD__);
84
        $this->assertGraphEquals(
85
            $expr,
86
            array(
87
                'PDepend\\Source\\AST\\ASTMemberPrimaryPrefix',
88
                'PDepend\\Source\\AST\\ASTSelfReference',
89
                'PDepend\\Source\\AST\\ASTPropertyPostfix',
90
                'PDepend\\Source\\AST\\ASTVariable'
91
            )
92
        );
93
    }
94
95
    /**
96
     * testPreDecrementExpressionOnParentClassMember
97
     *
98
     * @return void
99
     */
100 View Code Duplication
    public function testPreDecrementExpressionOnParentClassMember()
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...
101
    {
102
        $expr = $this->getFirstPreDecrementExpressionInClass(__METHOD__);
103
        $this->assertGraphEquals(
104
            $expr,
105
            array(
106
                'PDepend\\Source\\AST\\ASTMemberPrimaryPrefix',
107
                'PDepend\\Source\\AST\\ASTParentReference',
108
                'PDepend\\Source\\AST\\ASTPropertyPostfix',
109
                'PDepend\\Source\\AST\\ASTVariable'
110
            )
111
        );
112
    }
113
114
    /**
115
     * testPreDecrementExpressionOnFunctionPostfix
116
     *
117
     * @return void
118
     */
119
    public function testPreDecrementExpressionOnFunctionPostfix()
120
    {
121
        $expr = $this->getFirstPreDecrementExpressionInFunction(__METHOD__);
122
        $this->assertGraphEquals(
123
            $expr,
124
            array(
125
                'PDepend\\Source\\AST\\ASTFunctionPostfix',
126
                'PDepend\\Source\\AST\\ASTIdentifier',
127
                'PDepend\\Source\\AST\\ASTArguments'
128
            )
129
        );
130
    }
131
132
    /**
133
     * testPreDecrementExpressionOnStaticVariableMember
134
     *
135
     * @return void
136
     */
137 View Code Duplication
    public function testPreDecrementExpressionOnStaticVariableMember()
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...
138
    {
139
        $expr = $this->getFirstPreDecrementExpressionInFunction(__METHOD__);
140
        $this->assertGraphEquals(
141
            $expr,
142
            array(
143
                'PDepend\\Source\\AST\\ASTMemberPrimaryPrefix',
144
                'PDepend\\Source\\AST\\ASTVariable',
145
                'PDepend\\Source\\AST\\ASTPropertyPostfix',
146
                'PDepend\\Source\\AST\\ASTVariable'
147
            )
148
        );
149
    }
150
151
    /**
152
     * testPreDecrementExpressionHasExpectedStartLine
153
     *
154
     * @return void
155
     */
156
    public function testPreDecrementExpressionHasExpectedStartLine()
157
    {
158
        $expr = $this->getFirstPreDecrementExpressionInFunction(__METHOD__);
159
        $this->assertEquals(4, $expr->getStartLine());
160
    }
161
162
    /**
163
     * testPreDecrementExpressionHasExpectedStartColumn
164
     *
165
     * @return void
166
     */
167
    public function testPreDecrementExpressionHasExpectedStartColumn()
168
    {
169
        $expr = $this->getFirstPreDecrementExpressionInFunction(__METHOD__);
170
        $this->assertEquals(12, $expr->getStartColumn());
171
    }
172
173
    /**
174
     * testPreDecrementExpressionHasExpectedEndLine
175
     *
176
     * @return void
177
     */
178
    public function testPreDecrementExpressionHasExpectedEndLine()
179
    {
180
        $expr = $this->getFirstPreDecrementExpressionInFunction(__METHOD__);
181
        $this->assertEquals(7, $expr->getEndLine());
182
    }
183
184
    /**
185
     * testPreDecrementExpressionHasExpectedEndColumn
186
     *
187
     * @return void
188
     */
189
    public function testPreDecrementExpressionHasExpectedEndColumn()
190
    {
191
        $expr = $this->getFirstPreDecrementExpressionInFunction(__METHOD__);
192
        $this->assertEquals(21, $expr->getEndColumn());
193
    }
194
195
    /**
196
     * Returns a node instance for the currently executed test case.
197
     *
198
     * @param string $testCase Name of the calling test case.
199
     * @return \PDepend\Source\AST\ASTPreDecrementExpression
200
     */
201
    private function getFirstPreDecrementExpressionInClass($testCase)
202
    {
203
        return $this->getFirstNodeOfTypeInClass(
204
            $testCase,
205
            'PDepend\\Source\\AST\\ASTPreDecrementExpression'
206
        );
207
    }
208
209
    /**
210
     * Returns a node instance for the currently executed test case.
211
     *
212
     * @param string $testCase Name of the calling test case.
213
     *
214
     * @return \PDepend\Source\AST\ASTPreDecrementExpression
215
     */
216
    private function getFirstPreDecrementExpressionInFunction($testCase)
217
    {
218
        return $this->getFirstNodeOfTypeInFunction(
219
            $testCase,
220
            'PDepend\\Source\\AST\\ASTPreDecrementExpression'
221
        );
222
    }
223
}
224