Arbit - project tracking

PHPMD

Browse source code

File: / test/ PHP/ PMD/ Node/ AnnotationTest.php

Type
text/plain text/plain
Last Author
mapi
Version
200
Line Rev. Author Source
1 200 mapi <?php
2 mapi /**
3 mapi * This file is part of PHP_PMD.
4 mapi *
5 mapi * PHP Version 5
6 mapi *
7 mapi * Copyright (c) 2009-2010, Manuel Pichler <mapi@phpmd.org>.
8 mapi * All rights reserved.
9 mapi *
10 mapi * Redistribution and use in source and binary forms, with or without
11 mapi * modification, are permitted provided that the following conditions
12 mapi * are met:
13 mapi *
14 mapi * * Redistributions of source code must retain the above copyright
15 mapi * notice, this list of conditions and the following disclaimer.
16 mapi *
17 mapi * * Redistributions in binary form must reproduce the above copyright
18 mapi * notice, this list of conditions and the following disclaimer in
19 mapi * the documentation and/or other materials provided with the
20 mapi * distribution.
21 mapi *
22 mapi * * Neither the name of Manuel Pichler nor the names of his
23 mapi * contributors may be used to endorse or promote products derived
24 mapi * from this software without specific prior written permission.
25 mapi *
26 mapi * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 mapi * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 mapi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29 mapi * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30 mapi * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31 mapi * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32 mapi * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 mapi * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 mapi * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 mapi * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36 mapi * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 mapi * POSSIBILITY OF SUCH DAMAGE.
38 mapi *
39 mapi * @category PHP
40 mapi * @package PHP_PMD
41 mapi * @subpackage Node
42 mapi * @author Manuel Pichler <mapi@phpmd.org>
43 mapi * @copyright 2009-2010 Manuel Pichler. All rights reserved.
44 mapi * @license http://www.opensource.org/licenses/bsd-license.php BSD License
45 mapi * @version SVN: $Id$
46 mapi * @link http://phpmd.org
47 mapi */
48 mapi
49 mapi require_once dirname(__FILE__) . '/../AbstractTest.php';
50 mapi
51 mapi require_once 'PHP/PMD/Node/Annotation.php';
52 mapi
53 mapi /**
54 mapi * Test case for the {@link PHP_PMD_Node_Annotation} class.
55 mapi *
56 mapi * @category PHP
57 mapi * @package PHP_PMD
58 mapi * @subpackage Node
59 mapi * @author Manuel Pichler <mapi@phpmd.org>
60 mapi * @copyright 2009-2010 Manuel Pichler. All rights reserved.
61 mapi * @license http://www.opensource.org/licenses/bsd-license.php BSD License
62 mapi * @version Release: @package_version@
63 mapi * @link http://phpmd.org
64 mapi */
65 mapi class PHP_PMD_Node_AnnotationTest extends PHP_PMD_AbstractTest
66 mapi {
67 mapi /**
68 mapi * testAnnotationReturnsFalseWhenNoSuppressWarningAnnotationExists
69 mapi *
70 mapi * @return void
71 mapi * @covers PHP_PMD_Node_Annotation
72 mapi * @group phpmd
73 mapi * @group phpmd::node
74 mapi * @group unittest
75 mapi */
76 mapi public function testAnnotationReturnsFalseWhenNoSuppressWarningAnnotationExists()
77 mapi {
78 mapi $annotation = new PHP_PMD_Node_Annotation('NoSuppressWarning', 'PMD');
79 mapi $this->assertFalse($annotation->suppresses($this->getRuleMock()));
80 mapi }
81 mapi
82 mapi /**
83 mapi * testAnnotationReturnsFalseWhenSuppressWarningContainsInvalidValue
84 mapi *
85 mapi * @return void
86 mapi * @covers PHP_PMD_Node_Annotation
87 mapi * @group phpmd
88 mapi * @group phpmd::node
89 mapi * @group unittest
90 mapi */
91 mapi public function testAnnotationReturnsFalseWhenSuppressWarningContainsInvalidValue()
92 mapi {
93 mapi $annotation = new PHP_PMD_Node_Annotation('SuppressWarnings', 'PHP');
94 mapi $this->assertFalse($annotation->suppresses($this->getRuleMock()));
95 mapi }
96 mapi
97 mapi /**
98 mapi * testAnnotationReturnsTrueWhenSuppressWarningContainsWithPMD
99 mapi *
100 mapi * @return void
101 mapi * @covers PHP_PMD_Node_Annotation
102 mapi * @group phpmd
103 mapi * @group phpmd::node
104 mapi * @group unittest
105 mapi */
106 mapi public function testAnnotationReturnsTrueWhenSuppressWarningContainsWithPMD()
107 mapi {
108 mapi $annotation = new PHP_PMD_Node_Annotation('SuppressWarnings', 'PMD');
109 mapi $this->assertTrue($annotation->suppresses($this->getRuleMock()));
110 mapi }
111 mapi
112 mapi /**
113 mapi * testAnnotationReturnsTrueWhenSuppressWarningContainsWithPHPMD
114 mapi *
115 mapi * @return void
116 mapi * @covers PHP_PMD_Node_Annotation
117 mapi * @group phpmd
118 mapi * @group phpmd::node
119 mapi * @group unittest
120 mapi */
121 mapi public function testAnnotationReturnsTrueWhenSuppressWarningContainsWithPHPMD()
122 mapi {
123 mapi $annotation = new PHP_PMD_Node_Annotation('SuppressWarnings', 'PHPMD');
124 mapi $this->assertTrue($annotation->suppresses($this->getRuleMock()));
125 mapi }
126 mapi
127 mapi /**
128 mapi * testAnnotationReturnsTrueWhenSuppressWarningContainsPMDPlusRuleName
129 mapi *
130 mapi * @return void
131 mapi * @covers PHP_PMD_Node_Annotation
132 mapi * @group phpmd
133 mapi * @group phpmd::node
134 mapi * @group unittest
135 mapi */
136 mapi public function testAnnotationReturnsTrueWhenSuppressWarningContainsPMDPlusRuleName()
137 mapi {
138 mapi $rule = $this->getRuleMock();
139 mapi $rule->setName('UnusedCodeRule');
140 mapi
141 mapi $annotation = new PHP_PMD_Node_Annotation('SuppressWarnings', 'PMD.UnusedCodeRule');
142 mapi $this->assertTrue($annotation->suppresses($rule));
143 mapi }
144 mapi
145 mapi /**
146 mapi * testAnnotationReturnsTrueWhenSuppressWarningContainsPHPMDPlusRuleName
147 mapi *
148 mapi * @return void
149 mapi * @covers PHP_PMD_Node_Annotation
150 mapi * @group phpmd
151 mapi * @group phpmd::node
152 mapi * @group unittest
153 mapi */
154 mapi public function testAnnotationReturnsTrueWhenSuppressWarningContainsPHPMDPlusRuleName()
155 mapi {
156 mapi $rule = $this->getRuleMock();
157 mapi $rule->setName('UnusedCodeRule');
158 mapi
159 mapi $annotation = new PHP_PMD_Node_Annotation('SuppressWarnings', 'PHPMD.UnusedCodeRule');
160 mapi $this->assertTrue($annotation->suppresses($rule));
161 mapi }
162 mapi
163 mapi /**
164 mapi * testAnnotationReturnsTrueWhenSuppressWarningContainsPartialRuleName
165 mapi *
166 mapi * @return void
167 mapi * @covers PHP_PMD_Node_Annotation
168 mapi * @group phpmd
169 mapi * @group phpmd::node
170 mapi * @group unittest
171 mapi */
172 mapi public function testAnnotationReturnsTrueWhenSuppressWarningContainsPartialRuleName()
173 mapi {
174 mapi $rule = $this->getRuleMock();
175 mapi $rule->setName('UnusedCodeRule');
176 mapi
177 mapi $annotation = new PHP_PMD_Node_Annotation('SuppressWarnings', 'unused');
178 mapi $this->assertTrue($annotation->suppresses($rule));
179 mapi }
180 mapi }