| Conditions | 17 |
| Paths | > 20000 |
| Total Lines | 246 |
| Code Lines | 184 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 46 | final public function testEmptyElementIfIsReference() |
||
| 47 | { |
||
| 48 | /** @var FileSet $f */ |
||
| 49 | $f = $this->getInstance(); |
||
| 50 | $f->setIncludes("**/*.php"); |
||
| 51 | try { |
||
| 52 | $f->setRefid(new Reference($this->getProject(), "dummyref")); |
||
| 53 | $this->fail( |
||
| 54 | "Can add reference to " |
||
| 55 | . $f |
||
| 56 | . " with elements from setIncludes" |
||
| 57 | ); |
||
| 58 | } catch (BuildException $be) { |
||
| 59 | $this->assertEquals( |
||
| 60 | "You must not specify more than one attribute " |
||
| 61 | . "when using refid", |
||
| 62 | $be->getMessage() |
||
| 63 | ); |
||
| 64 | } |
||
| 65 | |||
| 66 | $f = $this->getInstance(); |
||
| 67 | $f->createPatternSet(); |
||
| 68 | try { |
||
| 69 | $f->setRefid(new Reference($this->getProject(), "dummyref")); |
||
| 70 | $this->fail( |
||
| 71 | "Can add reference to " |
||
| 72 | . $f |
||
| 73 | . " with nested patternset element." |
||
| 74 | ); |
||
| 75 | } catch (BuildException $be) { |
||
| 76 | $this->assertEquals( |
||
| 77 | "You must not specify nested elements when " |
||
| 78 | . "using refid", |
||
| 79 | $be->getMessage() |
||
| 80 | ); |
||
| 81 | } |
||
| 82 | |||
| 83 | $f = $this->getInstance(); |
||
| 84 | $f->createInclude(); |
||
| 85 | try { |
||
| 86 | $f->setRefid(new Reference($this->getProject(), "dummyref")); |
||
| 87 | $this->fail( |
||
| 88 | "Can add reference to " |
||
| 89 | . $f |
||
| 90 | . " with nested include element." |
||
| 91 | ); |
||
| 92 | } catch (BuildException $be) { |
||
| 93 | $this->assertEquals( |
||
| 94 | "You must not specify more than one attribute " |
||
| 95 | . "when using refid", |
||
| 96 | $be->getMessage() |
||
| 97 | ); |
||
| 98 | } |
||
| 99 | |||
| 100 | $f = $this->getInstance(); |
||
| 101 | $f->setRefid(new Reference($this->getProject(), "dummyref")); |
||
| 102 | try { |
||
| 103 | $f->setIncludes("**/*.java"); |
||
| 104 | $this->fail( |
||
| 105 | "Can set includes in " |
||
| 106 | . $f |
||
| 107 | . " that is a reference." |
||
| 108 | ); |
||
| 109 | } catch (BuildException $be) { |
||
| 110 | $this->assertEquals( |
||
| 111 | "You must not specify more than one attribute " |
||
| 112 | . "when using refid", |
||
| 113 | $be->getMessage() |
||
| 114 | ); |
||
| 115 | } |
||
| 116 | |||
| 117 | try { |
||
| 118 | $f->setIncludesfile(new PhingFile("/a")); |
||
| 119 | $this->fail( |
||
| 120 | "Can set includesfile in " |
||
| 121 | . $f |
||
| 122 | . " that is a reference." |
||
| 123 | ); |
||
| 124 | } catch (BuildException $be) { |
||
| 125 | $this->assertEquals( |
||
| 126 | "You must not specify more than one attribute " |
||
| 127 | . "when using refid", |
||
| 128 | $be->getMessage() |
||
| 129 | ); |
||
| 130 | } |
||
| 131 | |||
| 132 | try { |
||
| 133 | $f->setExcludes("**/*.java"); |
||
| 134 | $this->fail( |
||
| 135 | "Can set excludes in " |
||
| 136 | . $f |
||
| 137 | . " that is a reference." |
||
| 138 | ); |
||
| 139 | } catch (BuildException $be) { |
||
| 140 | $this->assertEquals( |
||
| 141 | "You must not specify more than one attribute " |
||
| 142 | . "when using refid", |
||
| 143 | $be->getMessage() |
||
| 144 | ); |
||
| 145 | } |
||
| 146 | |||
| 147 | try { |
||
| 148 | $f->setExcludesfile(new PhingFile("/a")); |
||
| 149 | $this->fail( |
||
| 150 | "Can set excludesfile in " |
||
| 151 | . $f |
||
| 152 | . " that is a reference." |
||
| 153 | ); |
||
| 154 | } catch (BuildException $be) { |
||
| 155 | $this->assertEquals( |
||
| 156 | "You must not specify more than one attribute " |
||
| 157 | . "when using refid", |
||
| 158 | $be->getMessage() |
||
| 159 | ); |
||
| 160 | } |
||
| 161 | |||
| 162 | try { |
||
| 163 | $f->setDir($this->project->resolveFile(".")); |
||
| 164 | $this->fail( |
||
| 165 | "Can set dir in " |
||
| 166 | . $f |
||
| 167 | . " that is a reference." |
||
| 168 | ); |
||
| 169 | } catch (BuildException $be) { |
||
| 170 | $this->assertEquals( |
||
| 171 | "You must not specify more than one attribute " |
||
| 172 | . "when using refid", |
||
| 173 | $be->getMessage() |
||
| 174 | ); |
||
| 175 | } |
||
| 176 | |||
| 177 | try { |
||
| 178 | $f->setExpandSymbolicLinks(true); |
||
| 179 | $this->fail( |
||
| 180 | "Can expand symbolic links in " |
||
| 181 | . $f |
||
| 182 | . " that is a reference." |
||
| 183 | ); |
||
| 184 | } catch (BuildException $be) { |
||
| 185 | $this->assertEquals( |
||
| 186 | "You must not specify more than one attribute " |
||
| 187 | . "when using refid", |
||
| 188 | $be->getMessage() |
||
| 189 | ); |
||
| 190 | } |
||
| 191 | |||
| 192 | try { |
||
| 193 | $f->setFile($this->project->resolveFile(__FILE__)); |
||
| 194 | $this->fail( |
||
| 195 | "Can set file in " |
||
| 196 | . $f |
||
| 197 | . " that is a reference." |
||
| 198 | ); |
||
| 199 | } catch (BuildException $be) { |
||
| 200 | $this->assertEquals( |
||
| 201 | "You must not specify more than one attribute " |
||
| 202 | . "when using refid", |
||
| 203 | $be->getMessage() |
||
| 204 | ); |
||
| 205 | } |
||
| 206 | |||
| 207 | try { |
||
| 208 | $f->setCaseSensitive(true); |
||
| 209 | $this->fail( |
||
| 210 | "Can set case sensitive in " |
||
| 211 | . $f |
||
| 212 | . " that is a reference." |
||
| 213 | ); |
||
| 214 | } catch (BuildException $be) { |
||
| 215 | $this->assertEquals( |
||
| 216 | "You must not specify more than one attribute " |
||
| 217 | . "when using refid", |
||
| 218 | $be->getMessage() |
||
| 219 | ); |
||
| 220 | } |
||
| 221 | |||
| 222 | try { |
||
| 223 | $f->createInclude(); |
||
| 224 | $this->fail( |
||
| 225 | "Can add nested include in " |
||
| 226 | . $f |
||
| 227 | . " that is a reference." |
||
| 228 | ); |
||
| 229 | } catch (BuildException $be) { |
||
| 230 | $this->assertEquals( |
||
| 231 | "You must not specify nested elements when using " |
||
| 232 | . "refid", |
||
| 233 | $be->getMessage() |
||
| 234 | ); |
||
| 235 | } |
||
| 236 | |||
| 237 | try { |
||
| 238 | $f->createExclude(); |
||
| 239 | $this->fail( |
||
| 240 | "Can add nested exclude in " |
||
| 241 | . $f |
||
| 242 | . " that is a reference." |
||
| 243 | ); |
||
| 244 | } catch (BuildException $be) { |
||
| 245 | $this->assertEquals( |
||
| 246 | "You must not specify nested elements when using " |
||
| 247 | . "refid", |
||
| 248 | $be->getMessage() |
||
| 249 | ); |
||
| 250 | } |
||
| 251 | |||
| 252 | try { |
||
| 253 | $f->createIncludesFile(); |
||
| 254 | $this->fail( |
||
| 255 | "Can add nested includesfile in " |
||
| 256 | . $f |
||
| 257 | . " that is a reference." |
||
| 258 | ); |
||
| 259 | } catch (BuildException $be) { |
||
| 260 | $this->assertEquals( |
||
| 261 | "You must not specify nested elements when using " |
||
| 262 | . "refid", |
||
| 263 | $be->getMessage() |
||
| 264 | ); |
||
| 265 | } |
||
| 266 | try { |
||
| 267 | $f->createExcludesFile(); |
||
| 268 | $this->fail( |
||
| 269 | "Can add nested excludesfile in " |
||
| 270 | . $f |
||
| 271 | . " that is a reference." |
||
| 272 | ); |
||
| 273 | } catch (BuildException $be) { |
||
| 274 | $this->assertEquals( |
||
| 275 | "You must not specify nested elements when using " |
||
| 276 | . "refid", |
||
| 277 | $be->getMessage() |
||
| 278 | ); |
||
| 279 | } |
||
| 280 | try { |
||
| 281 | $f->createPatternSet(); |
||
| 282 | $this->fail( |
||
| 283 | "Can add nested patternset in " |
||
| 284 | . $f |
||
| 285 | . " that is a reference." |
||
| 286 | ); |
||
| 287 | } catch (BuildException $be) { |
||
| 288 | $this->assertEquals( |
||
| 289 | "You must not specify nested elements when using " |
||
| 290 | . "refid", |
||
| 291 | $be->getMessage() |
||
| 292 | ); |
||
| 296 |