How to use eol class

Best Atoum code snippet using eol

ErrorSuppressionTest.php

Source:ErrorSuppressionTest.php Github

copy

Full Screen

1<?php2/**3 * Tests for PHP_CodeSniffer error suppression tags.4 *5 * @author Greg Sherwood <gsherwood@squiz.net>6 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)7 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence8 */9namespace PHP_CodeSniffer\Tests\Core;10use PHP_CodeSniffer\Config;11use PHP_CodeSniffer\Ruleset;12use PHP_CodeSniffer\Files\DummyFile;13use PHPUnit\Framework\TestCase;14class ErrorSuppressionTest extends TestCase15{16 /**17 * Test suppressing a single error.18 *19 * @return void20 */21 public function testSuppressError()22 {23 $config = new Config();24 $config->standards = ['Generic'];25 $config->sniffs = ['Generic.PHP.LowerCaseConstant'];26 $ruleset = new Ruleset($config);27 // Process without suppression.28 $content = '<?php '.PHP_EOL.'$var = FALSE;';29 $file = new DummyFile($content, $ruleset, $config);30 $file->process();31 $errors = $file->getErrors();32 $numErrors = $file->getErrorCount();33 $this->assertEquals(1, $numErrors);34 $this->assertCount(1, $errors);35 // Process with inline comment suppression.36 $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// phpcs:enable';37 $file = new DummyFile($content, $ruleset, $config);38 $file->process();39 $errors = $file->getErrors();40 $numErrors = $file->getErrorCount();41 $this->assertEquals(0, $numErrors);42 $this->assertCount(0, $errors);43 // Process with multi-line inline comment suppression, tab-indented.44 $content = '<?php '.PHP_EOL."\t".'// For reasons'.PHP_EOL."\t".'// phpcs:disable'.PHP_EOL."\t".'$var = FALSE;'.PHP_EOL."\t".'// phpcs:enable';45 $file = new DummyFile($content, $ruleset, $config);46 $file->process();47 $errors = $file->getErrors();48 $numErrors = $file->getErrorCount();49 $this->assertEquals(0, $numErrors);50 $this->assertCount(0, $errors);51 // Process with inline @ comment suppression.52 $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// @phpcs:enable';53 $file = new DummyFile($content, $ruleset, $config);54 $file->process();55 $errors = $file->getErrors();56 $numErrors = $file->getErrorCount();57 $this->assertEquals(0, $numErrors);58 $this->assertCount(0, $errors);59 // Process with inline comment suppression mixed case.60 $content = '<?php '.PHP_EOL.'// PHPCS:Disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// pHPcs:enabLE';61 $file = new DummyFile($content, $ruleset, $config);62 $file->process();63 $errors = $file->getErrors();64 $numErrors = $file->getErrorCount();65 $this->assertEquals(0, $numErrors);66 $this->assertCount(0, $errors);67 // Process with inline comment suppression (deprecated syntax).68 $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// @codingStandardsIgnoreEnd';69 $file = new DummyFile($content, $ruleset, $config);70 $file->process();71 $errors = $file->getErrors();72 $numErrors = $file->getErrorCount();73 $this->assertEquals(0, $numErrors);74 $this->assertCount(0, $errors);75 // Process with block comment suppression.76 $content = '<?php '.PHP_EOL.'/* phpcs:disable */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/* phpcs:enable */';77 $file = new DummyFile($content, $ruleset, $config);78 $file->process();79 $errors = $file->getErrors();80 $numErrors = $file->getErrorCount();81 $this->assertEquals(0, $numErrors);82 $this->assertCount(0, $errors);83 // Process with multi-line block comment suppression.84 $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' phpcs:disable'.PHP_EOL.' */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/*'.PHP_EOL.' phpcs:enable'.PHP_EOL.' */';85 $file = new DummyFile($content, $ruleset, $config);86 $file->process();87 $errors = $file->getErrors();88 $numErrors = $file->getErrorCount();89 $this->assertEquals(0, $numErrors);90 $this->assertCount(0, $errors);91 // Process with multi-line block comment suppression, each line starred.92 $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' * phpcs:disable'.PHP_EOL.' */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/*'.PHP_EOL.' * phpcs:enable'.PHP_EOL.' */';93 $file = new DummyFile($content, $ruleset, $config);94 $file->process();95 $errors = $file->getErrors();96 $numErrors = $file->getErrorCount();97 $this->assertEquals(0, $numErrors);98 $this->assertCount(0, $errors);99 // Process with multi-line block comment suppression, tab-indented.100 $content = '<?php '.PHP_EOL."\t".'/*'.PHP_EOL."\t".' * phpcs:disable'.PHP_EOL."\t".' */'.PHP_EOL."\t".'$var = FALSE;'.PHP_EOL."\t".'/*'.PHP_EOL.' * phpcs:enable'.PHP_EOL.' */';101 $file = new DummyFile($content, $ruleset, $config);102 $file->process();103 $errors = $file->getErrors();104 $numErrors = $file->getErrorCount();105 $this->assertEquals(0, $numErrors);106 $this->assertCount(0, $errors);107 // Process with block comment suppression (deprecated syntax).108 $content = '<?php '.PHP_EOL.'/* @codingStandardsIgnoreStart */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/* @codingStandardsIgnoreEnd */';109 $file = new DummyFile($content, $ruleset, $config);110 $file->process();111 $errors = $file->getErrors();112 $numErrors = $file->getErrorCount();113 $this->assertEquals(0, $numErrors);114 $this->assertCount(0, $errors);115 // Process with multi-line block comment suppression (deprecated syntax).116 $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' @codingStandardsIgnoreStart'.PHP_EOL.' */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/*'.PHP_EOL.' @codingStandardsIgnoreEnd'.PHP_EOL.' */';117 $file = new DummyFile($content, $ruleset, $config);118 $file->process();119 $errors = $file->getErrors();120 $numErrors = $file->getErrorCount();121 $this->assertEquals(0, $numErrors);122 $this->assertCount(0, $errors);123 // Process with a docblock suppression.124 $content = '<?php '.PHP_EOL.'/** phpcs:disable */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/** phpcs:enable */';125 $file = new DummyFile($content, $ruleset, $config);126 $file->process();127 $errors = $file->getErrors();128 $numErrors = $file->getErrorCount();129 $this->assertEquals(0, $numErrors);130 $this->assertCount(0, $errors);131 // Process with a docblock suppression (deprecated syntax).132 $content = '<?php '.PHP_EOL.'/** @codingStandardsIgnoreStart */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/** @codingStandardsIgnoreEnd */';133 $file = new DummyFile($content, $ruleset, $config);134 $file->process();135 $errors = $file->getErrors();136 $numErrors = $file->getErrorCount();137 $this->assertEquals(0, $numErrors);138 $this->assertCount(0, $errors);139 }//end testSuppressError()140 /**141 * Test suppressing 1 out of 2 errors.142 *143 * @return void144 */145 public function testSuppressSomeErrors()146 {147 $config = new Config();148 $config->standards = ['Generic'];149 $config->sniffs = ['Generic.PHP.LowerCaseConstant'];150 $ruleset = new Ruleset($config);151 // Process without suppression.152 $content = '<?php '.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;';153 $file = new DummyFile($content, $ruleset, $config);154 $file->process();155 $errors = $file->getErrors();156 $numErrors = $file->getErrorCount();157 $this->assertEquals(2, $numErrors);158 $this->assertCount(2, $errors);159 // Process with suppression.160 $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// phpcs:enable'.PHP_EOL.'$var = TRUE;';161 $file = new DummyFile($content, $ruleset, $config);162 $file->process();163 $errors = $file->getErrors();164 $numErrors = $file->getErrorCount();165 $this->assertEquals(1, $numErrors);166 $this->assertCount(1, $errors);167 // Process with @ suppression.168 $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// @phpcs:enable'.PHP_EOL.'$var = TRUE;';169 $file = new DummyFile($content, $ruleset, $config);170 $file->process();171 $errors = $file->getErrors();172 $numErrors = $file->getErrorCount();173 $this->assertEquals(1, $numErrors);174 $this->assertCount(1, $errors);175 // Process with suppression (deprecated syntax).176 $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// @codingStandardsIgnoreEnd'.PHP_EOL.'$var = TRUE;';177 $file = new DummyFile($content, $ruleset, $config);178 $file->process();179 $errors = $file->getErrors();180 $numErrors = $file->getErrorCount();181 $this->assertEquals(1, $numErrors);182 $this->assertCount(1, $errors);183 // Process with a PHPDoc block suppression.184 $content = '<?php '.PHP_EOL.'/** phpcs:disable */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/** phpcs:enable */'.PHP_EOL.'$var = TRUE;';185 $file = new DummyFile($content, $ruleset, $config);186 $file->process();187 $errors = $file->getErrors();188 $numErrors = $file->getErrorCount();189 $this->assertEquals(1, $numErrors);190 $this->assertCount(1, $errors);191 // Process with a PHPDoc block suppression (deprecated syntax).192 $content = '<?php '.PHP_EOL.'/** @codingStandardsIgnoreStart */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'/** @codingStandardsIgnoreEnd */'.PHP_EOL.'$var = TRUE;';193 $file = new DummyFile($content, $ruleset, $config);194 $file->process();195 $errors = $file->getErrors();196 $numErrors = $file->getErrorCount();197 $this->assertEquals(1, $numErrors);198 $this->assertCount(1, $errors);199 }//end testSuppressSomeErrors()200 /**201 * Test suppressing a single warning.202 *203 * @return void204 */205 public function testSuppressWarning()206 {207 $config = new Config();208 $config->standards = ['Generic'];209 $config->sniffs = ['Generic.Commenting.Todo'];210 $ruleset = new Ruleset($config);211 // Process without suppression.212 $content = '<?php '.PHP_EOL.'//TODO: write some code';213 $file = new DummyFile($content, $ruleset, $config);214 $file->process();215 $warnings = $file->getWarnings();216 $numWarnings = $file->getWarningCount();217 $this->assertEquals(1, $numWarnings);218 $this->assertCount(1, $warnings);219 // Process with suppression.220 $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable';221 $file = new DummyFile($content, $ruleset, $config);222 $file->process();223 $warnings = $file->getWarnings();224 $numWarnings = $file->getWarningCount();225 $this->assertEquals(0, $numWarnings);226 $this->assertCount(0, $warnings);227 // Process with @ suppression.228 $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// @phpcs:enable';229 $file = new DummyFile($content, $ruleset, $config);230 $file->process();231 $warnings = $file->getWarnings();232 $numWarnings = $file->getWarningCount();233 $this->assertEquals(0, $numWarnings);234 $this->assertCount(0, $warnings);235 // Process with suppression (deprecated syntax).236 $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// @codingStandardsIgnoreEnd';237 $file = new DummyFile($content, $ruleset, $config);238 $file->process();239 $warnings = $file->getWarnings();240 $numWarnings = $file->getWarningCount();241 $this->assertEquals(0, $numWarnings);242 $this->assertCount(0, $warnings);243 // Process with a docblock suppression.244 $content = '<?php '.PHP_EOL.'/** phpcs:disable */'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'/** phpcs:enable */';245 $file = new DummyFile($content, $ruleset, $config);246 $file->process();247 $warnings = $file->getWarnings();248 $numWarnings = $file->getWarningCount();249 $this->assertEquals(0, $numWarnings);250 $this->assertCount(0, $warnings);251 // Process with a docblock suppression (deprecated syntax).252 $content = '<?php '.PHP_EOL.'/** @codingStandardsIgnoreStart */'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'/** @codingStandardsIgnoreEnd */';253 $file = new DummyFile($content, $ruleset, $config);254 $file->process();255 $warnings = $file->getWarnings();256 $numWarnings = $file->getWarningCount();257 $this->assertEquals(0, $numWarnings);258 $this->assertCount(0, $warnings);259 }//end testSuppressWarning()260 /**261 * Test suppressing a single error using a single line ignore.262 *263 * @return void264 */265 public function testSuppressLine()266 {267 $config = new Config();268 $config->standards = ['Generic'];269 $config->sniffs = ['Generic.PHP.LowerCaseConstant'];270 $ruleset = new Ruleset($config);271 // Process without suppression.272 $content = '<?php '.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;';273 $file = new DummyFile($content, $ruleset, $config);274 $file->process();275 $errors = $file->getErrors();276 $numErrors = $file->getErrorCount();277 $this->assertEquals(2, $numErrors);278 $this->assertCount(2, $errors);279 // Process with suppression on line before.280 $content = '<?php '.PHP_EOL.'// phpcs:ignore'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;';281 $file = new DummyFile($content, $ruleset, $config);282 $file->process();283 $errors = $file->getErrors();284 $numErrors = $file->getErrorCount();285 $this->assertEquals(1, $numErrors);286 $this->assertCount(1, $errors);287 // Process with @ suppression on line before.288 $content = '<?php '.PHP_EOL.'// @phpcs:ignore'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;';289 $file = new DummyFile($content, $ruleset, $config);290 $file->process();291 $errors = $file->getErrors();292 $numErrors = $file->getErrorCount();293 $this->assertEquals(1, $numErrors);294 $this->assertCount(1, $errors);295 // Process with suppression on line before.296 $content = '<?php '.PHP_EOL.'/* phpcs:ignore */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;';297 $file = new DummyFile($content, $ruleset, $config);298 $file->process();299 $errors = $file->getErrors();300 $numErrors = $file->getErrorCount();301 $this->assertEquals(1, $numErrors);302 $this->assertCount(1, $errors);303 // Process with @ suppression on line before.304 $content = '<?php '.PHP_EOL.'/* @phpcs:ignore */'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;';305 $file = new DummyFile($content, $ruleset, $config);306 $file->process();307 $errors = $file->getErrors();308 $numErrors = $file->getErrorCount();309 $this->assertEquals(1, $numErrors);310 $this->assertCount(1, $errors);311 // Process with suppression on line before (deprecated syntax).312 $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreLine'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = FALSE;';313 $file = new DummyFile($content, $ruleset, $config);314 $file->process();315 $errors = $file->getErrors();316 $numErrors = $file->getErrorCount();317 $this->assertEquals(1, $numErrors);318 $this->assertCount(1, $errors);319 // Process with suppression on same line.320 $content = '<?php '.PHP_EOL.'$var = FALSE; // phpcs:ignore'.PHP_EOL.'$var = FALSE;';321 $file = new DummyFile($content, $ruleset, $config);322 $file->process();323 $errors = $file->getErrors();324 $numErrors = $file->getErrorCount();325 $this->assertEquals(1, $numErrors);326 $this->assertCount(1, $errors);327 // Process with @ suppression on same line.328 $content = '<?php '.PHP_EOL.'$var = FALSE; // @phpcs:ignore'.PHP_EOL.'$var = FALSE;';329 $file = new DummyFile($content, $ruleset, $config);330 $file->process();331 $errors = $file->getErrors();332 $numErrors = $file->getErrorCount();333 $this->assertEquals(1, $numErrors);334 $this->assertCount(1, $errors);335 // Process with suppression on same line (deprecated syntax).336 $content = '<?php '.PHP_EOL.'$var = FALSE; // @codingStandardsIgnoreLine'.PHP_EOL.'$var = FALSE;';337 $file = new DummyFile($content, $ruleset, $config);338 $file->process();339 $errors = $file->getErrors();340 $numErrors = $file->getErrorCount();341 $this->assertEquals(1, $numErrors);342 $this->assertCount(1, $errors);343 }//end testSuppressLine()344 /**345 * Test that using a single line ignore does not interfere with other suppressions.346 *347 * @return void348 */349 public function testNestedSuppressLine()350 {351 $config = new Config();352 $config->standards = ['Generic'];353 $config->sniffs = ['Generic.PHP.LowerCaseConstant'];354 $ruleset = new Ruleset($config);355 // Process with disable/enable suppression and no single line suppression.356 $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// phpcs:enable';357 $file = new DummyFile($content, $ruleset, $config);358 $file->process();359 $errors = $file->getErrors();360 $numErrors = $file->getErrorCount();361 $this->assertEquals(0, $numErrors);362 $this->assertCount(0, $errors);363 // Process with disable/enable @ suppression and no single line suppression.364 $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// @phpcs:enable';365 $file = new DummyFile($content, $ruleset, $config);366 $file->process();367 $errors = $file->getErrors();368 $numErrors = $file->getErrorCount();369 $this->assertEquals(0, $numErrors);370 $this->assertCount(0, $errors);371 // Process with disable/enable suppression and no single line suppression (deprecated syntax).372 $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// @codingStandardsIgnoreEnd';373 $file = new DummyFile($content, $ruleset, $config);374 $file->process();375 $errors = $file->getErrors();376 $numErrors = $file->getErrorCount();377 $this->assertEquals(0, $numErrors);378 $this->assertCount(0, $errors);379 // Process with line suppression nested within disable/enable suppression.380 $content = '<?php '.PHP_EOL.'// phpcs:disable'.PHP_EOL.'// phpcs:ignore'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// phpcs:enable';381 $file = new DummyFile($content, $ruleset, $config);382 $file->process();383 $errors = $file->getErrors();384 $numErrors = $file->getErrorCount();385 $this->assertEquals(0, $numErrors);386 $this->assertCount(0, $errors);387 // Process with line @ suppression nested within disable/enable @ suppression.388 $content = '<?php '.PHP_EOL.'// @phpcs:disable'.PHP_EOL.'// @phpcs:ignore'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// @phpcs:enable';389 $file = new DummyFile($content, $ruleset, $config);390 $file->process();391 $errors = $file->getErrors();392 $numErrors = $file->getErrorCount();393 $this->assertEquals(0, $numErrors);394 $this->assertCount(0, $errors);395 // Process with line suppression nested within disable/enable suppression (deprecated syntax).396 $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreStart'.PHP_EOL.'// @codingStandardsIgnoreLine'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'$var = TRUE;'.PHP_EOL.'// @codingStandardsIgnoreEnd';397 $file = new DummyFile($content, $ruleset, $config);398 $file->process();399 $errors = $file->getErrors();400 $numErrors = $file->getErrorCount();401 $this->assertEquals(0, $numErrors);402 $this->assertCount(0, $errors);403 }//end testNestedSuppressLine()404 /**405 * Test suppressing a scope opener.406 *407 * @return void408 */409 public function testSuppressScope()410 {411 $config = new Config();412 $config->standards = ['PEAR'];413 $config->sniffs = ['PEAR.NamingConventions.ValidVariableName'];414 $ruleset = new Ruleset($config);415 // Process without suppression.416 $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'function myFunction() {'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}';417 $file = new DummyFile($content, $ruleset, $config);418 $file->process();419 $errors = $file->getErrors();420 $numErrors = $file->getErrorCount();421 $this->assertEquals(0, $numErrors);422 $this->assertCount(0, $errors);423 // Process with suppression.424 $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'//phpcs:disable'.PHP_EOL.'function myFunction() {'.PHP_EOL.'//phpcs:enable'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}';425 $file = new DummyFile($content, $ruleset, $config);426 $file->process();427 $errors = $file->getErrors();428 $numErrors = $file->getErrorCount();429 $this->assertEquals(0, $numErrors);430 $this->assertCount(0, $errors);431 // Process with suppression.432 $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'//@phpcs:disable'.PHP_EOL.'function myFunction() {'.PHP_EOL.'//@phpcs:enable'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}';433 $file = new DummyFile($content, $ruleset, $config);434 $file->process();435 $errors = $file->getErrors();436 $numErrors = $file->getErrorCount();437 $this->assertEquals(0, $numErrors);438 $this->assertCount(0, $errors);439 // Process with suppression (deprecated syntax).440 $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'//@codingStandardsIgnoreStart'.PHP_EOL.'function myFunction() {'.PHP_EOL.'//@codingStandardsIgnoreEnd'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}';441 $file = new DummyFile($content, $ruleset, $config);442 $file->process();443 $errors = $file->getErrors();444 $numErrors = $file->getErrorCount();445 $this->assertEquals(0, $numErrors);446 $this->assertCount(0, $errors);447 // Process with a docblock suppression.448 $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'/** phpcs:disable */'.PHP_EOL.'function myFunction() {'.PHP_EOL.'/** phpcs:enable */'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}';449 $file = new DummyFile($content, $ruleset, $config);450 $errors = $file->getErrors();451 $numErrors = $file->getErrorCount();452 $this->assertEquals(0, $numErrors);453 $this->assertCount(0, $errors);454 // Process with a docblock @ suppression.455 $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'/** @phpcs:disable */'.PHP_EOL.'function myFunction() {'.PHP_EOL.'/** @phpcs:enable */'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}';456 $file = new DummyFile($content, $ruleset, $config);457 $errors = $file->getErrors();458 $numErrors = $file->getErrorCount();459 $this->assertEquals(0, $numErrors);460 $this->assertCount(0, $errors);461 // Process with a docblock suppression (deprecated syntax).462 $content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'/** @codingStandardsIgnoreStart */'.PHP_EOL.'function myFunction() {'.PHP_EOL.'/** @codingStandardsIgnoreEnd */'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}';463 $file = new DummyFile($content, $ruleset, $config);464 $errors = $file->getErrors();465 $numErrors = $file->getErrorCount();466 $this->assertEquals(0, $numErrors);467 $this->assertCount(0, $errors);468 }//end testSuppressScope()469 /**470 * Test suppressing a whole file.471 *472 * @return void473 */474 public function testSuppressFile()475 {476 $config = new Config();477 $config->standards = ['Generic'];478 $config->sniffs = ['Generic.Commenting.Todo'];479 $ruleset = new Ruleset($config);480 // Process without suppression.481 $content = '<?php '.PHP_EOL.'//TODO: write some code';482 $file = new DummyFile($content, $ruleset, $config);483 $file->process();484 $warnings = $file->getWarnings();485 $numWarnings = $file->getWarningCount();486 $this->assertEquals(1, $numWarnings);487 $this->assertCount(1, $warnings);488 // Process with suppression.489 $content = '<?php '.PHP_EOL.'// phpcs:ignoreFile'.PHP_EOL.'//TODO: write some code';490 $file = new DummyFile($content, $ruleset, $config);491 $file->process();492 $warnings = $file->getWarnings();493 $numWarnings = $file->getWarningCount();494 $this->assertEquals(0, $numWarnings);495 $this->assertCount(0, $warnings);496 // Process with @ suppression.497 $content = '<?php '.PHP_EOL.'// @phpcs:ignoreFile'.PHP_EOL.'//TODO: write some code';498 $file = new DummyFile($content, $ruleset, $config);499 $file->process();500 $warnings = $file->getWarnings();501 $numWarnings = $file->getWarningCount();502 $this->assertEquals(0, $numWarnings);503 $this->assertCount(0, $warnings);504 // Process with suppression (deprecated syntax).505 $content = '<?php '.PHP_EOL.'// @codingStandardsIgnoreFile'.PHP_EOL.'//TODO: write some code';506 $file = new DummyFile($content, $ruleset, $config);507 $file->process();508 $warnings = $file->getWarnings();509 $numWarnings = $file->getWarningCount();510 $this->assertEquals(0, $numWarnings);511 $this->assertCount(0, $warnings);512 // Process mixed case.513 $content = '<?php '.PHP_EOL.'// PHPCS:Ignorefile'.PHP_EOL.'//TODO: write some code';514 $file = new DummyFile($content, $ruleset, $config);515 $file->process();516 $warnings = $file->getWarnings();517 $numWarnings = $file->getWarningCount();518 $this->assertEquals(0, $numWarnings);519 $this->assertCount(0, $warnings);520 // Process late comment.521 $content = '<?php '.PHP_EOL.'class MyClass {}'.PHP_EOL.'$foo = new MyClass()'.PHP_EOL.'// phpcs:ignoreFile';522 $file = new DummyFile($content, $ruleset, $config);523 $file->process();524 $warnings = $file->getWarnings();525 $numWarnings = $file->getWarningCount();526 $this->assertEquals(0, $numWarnings);527 $this->assertCount(0, $warnings);528 // Process late comment (deprecated syntax).529 $content = '<?php '.PHP_EOL.'class MyClass {}'.PHP_EOL.'$foo = new MyClass()'.PHP_EOL.'// @codingStandardsIgnoreFile';530 $file = new DummyFile($content, $ruleset, $config);531 $file->process();532 $warnings = $file->getWarnings();533 $numWarnings = $file->getWarningCount();534 $this->assertEquals(0, $numWarnings);535 $this->assertCount(0, $warnings);536 // Process with a block comment suppression.537 $content = '<?php '.PHP_EOL.'/* phpcs:ignoreFile */'.PHP_EOL.'//TODO: write some code';538 $file = new DummyFile($content, $ruleset, $config);539 $file->process();540 $warnings = $file->getWarnings();541 $numWarnings = $file->getWarningCount();542 $this->assertEquals(0, $numWarnings);543 $this->assertCount(0, $warnings);544 // Process with a multi-line block comment suppression.545 $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' phpcs:ignoreFile'.PHP_EOL.' */'.PHP_EOL.'//TODO: write some code';546 $file = new DummyFile($content, $ruleset, $config);547 $file->process();548 $warnings = $file->getWarnings();549 $numWarnings = $file->getWarningCount();550 $this->assertEquals(0, $numWarnings);551 $this->assertCount(0, $warnings);552 // Process with a block comment suppression (deprecated syntax).553 $content = '<?php '.PHP_EOL.'/* @codingStandardsIgnoreFile */'.PHP_EOL.'//TODO: write some code';554 $file = new DummyFile($content, $ruleset, $config);555 $file->process();556 $warnings = $file->getWarnings();557 $numWarnings = $file->getWarningCount();558 $this->assertEquals(0, $numWarnings);559 $this->assertCount(0, $warnings);560 // Process with a multi-line block comment suppression (deprecated syntax).561 $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' @codingStandardsIgnoreFile'.PHP_EOL.' */'.PHP_EOL.'//TODO: write some code';562 $file = new DummyFile($content, $ruleset, $config);563 $file->process();564 $warnings = $file->getWarnings();565 $numWarnings = $file->getWarningCount();566 $this->assertEquals(0, $numWarnings);567 $this->assertCount(0, $warnings);568 // Process with docblock suppression.569 $content = '<?php '.PHP_EOL.'/** phpcs:ignoreFile */'.PHP_EOL.'//TODO: write some code';570 $file = new DummyFile($content, $ruleset, $config);571 $file->process();572 $warnings = $file->getWarnings();573 $numWarnings = $file->getWarningCount();574 $this->assertEquals(0, $numWarnings);575 $this->assertCount(0, $warnings);576 // Process with docblock suppression (deprecated syntax).577 $content = '<?php '.PHP_EOL.'/** @codingStandardsIgnoreFile */'.PHP_EOL.'//TODO: write some code';578 $file = new DummyFile($content, $ruleset, $config);579 $file->process();580 $warnings = $file->getWarnings();581 $numWarnings = $file->getWarningCount();582 $this->assertEquals(0, $numWarnings);583 $this->assertCount(0, $warnings);584 }//end testSuppressFile()585 /**586 * Test disabling specific sniffs.587 *588 * @return void589 */590 public function testDisableSelected()591 {592 $config = new Config();593 $config->standards = ['Generic'];594 $config->sniffs = [595 'Generic.PHP.LowerCaseConstant',596 'Generic.Commenting.Todo',597 ];598 $ruleset = new Ruleset($config);599 // Suppress a single sniff.600 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code';601 $file = new DummyFile($content, $ruleset, $config);602 $file->process();603 $errors = $file->getErrors();604 $numErrors = $file->getErrorCount();605 $warnings = $file->getWarnings();606 $numWarnings = $file->getWarningCount();607 $this->assertEquals(1, $numErrors);608 $this->assertCount(1, $errors);609 $this->assertEquals(0, $numWarnings);610 $this->assertCount(0, $warnings);611 // Suppress multiple sniffs.612 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code';613 $file = new DummyFile($content, $ruleset, $config);614 $file->process();615 $errors = $file->getErrors();616 $numErrors = $file->getErrorCount();617 $warnings = $file->getWarnings();618 $numWarnings = $file->getWarningCount();619 $this->assertEquals(0, $numErrors);620 $this->assertCount(0, $errors);621 $this->assertEquals(0, $numWarnings);622 $this->assertCount(0, $warnings);623 // Suppress adding sniffs.624 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'// phpcs:disable Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code';625 $file = new DummyFile($content, $ruleset, $config);626 $file->process();627 $errors = $file->getErrors();628 $numErrors = $file->getErrorCount();629 $warnings = $file->getWarnings();630 $numWarnings = $file->getWarningCount();631 $this->assertEquals(0, $numErrors);632 $this->assertCount(0, $errors);633 $this->assertEquals(0, $numWarnings);634 $this->assertCount(0, $warnings);635 // Suppress a category of sniffs.636 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code';637 $file = new DummyFile($content, $ruleset, $config);638 $file->process();639 $errors = $file->getErrors();640 $numErrors = $file->getErrorCount();641 $warnings = $file->getWarnings();642 $numWarnings = $file->getWarningCount();643 $this->assertEquals(1, $numErrors);644 $this->assertCount(1, $errors);645 $this->assertEquals(0, $numWarnings);646 $this->assertCount(0, $warnings);647 // Suppress a whole standard.648 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code';649 $file = new DummyFile($content, $ruleset, $config);650 $file->process();651 $errors = $file->getErrors();652 $numErrors = $file->getErrorCount();653 $warnings = $file->getWarnings();654 $numWarnings = $file->getWarningCount();655 $this->assertEquals(0, $numErrors);656 $this->assertCount(0, $errors);657 $this->assertEquals(0, $numWarnings);658 $this->assertCount(0, $warnings);659 // Suppress using docblocks.660 $content = '<?php '.PHP_EOL.'/**661 '.PHP_EOL.' * phpcs:disable Generic.Commenting.Todo'.PHP_EOL.' */ '.PHP_EOL.'//TODO: write some code';662 $file = new DummyFile($content, $ruleset, $config);663 $file->process();664 $errors = $file->getErrors();665 $numErrors = $file->getErrorCount();666 $warnings = $file->getWarnings();667 $numWarnings = $file->getWarningCount();668 $this->assertEquals(0, $numErrors);669 $this->assertCount(0, $errors);670 $this->assertEquals(0, $numWarnings);671 $this->assertCount(0, $warnings);672 $content = '<?php '.PHP_EOL.'/**673 '.PHP_EOL.' * @phpcs:disable Generic.Commenting.Todo'.PHP_EOL.' */ '.PHP_EOL.'//TODO: write some code';674 $file = new DummyFile($content, $ruleset, $config);675 $file->process();676 $errors = $file->getErrors();677 $numErrors = $file->getErrorCount();678 $warnings = $file->getWarnings();679 $numWarnings = $file->getWarningCount();680 $this->assertEquals(0, $numErrors);681 $this->assertCount(0, $errors);682 $this->assertEquals(0, $numWarnings);683 $this->assertCount(0, $warnings);684 // Suppress wrong category using docblocks.685 $content = '<?php '.PHP_EOL.'/**686 '.PHP_EOL.' * phpcs:disable Generic.Files'.PHP_EOL.' */ '.PHP_EOL.'//TODO: write some code';687 $file = new DummyFile($content, $ruleset, $config);688 $file->process();689 $errors = $file->getErrors();690 $numErrors = $file->getErrorCount();691 $warnings = $file->getWarnings();692 $numWarnings = $file->getWarningCount();693 $this->assertEquals(0, $numErrors);694 $this->assertCount(0, $errors);695 $this->assertEquals(1, $numWarnings);696 $this->assertCount(1, $warnings);697 $content = '<?php '.PHP_EOL.'/**698 '.PHP_EOL.' * @phpcs:disable Generic.Files'.PHP_EOL.' */ '.PHP_EOL.'//TODO: write some code';699 $file = new DummyFile($content, $ruleset, $config);700 $file->process();701 $errors = $file->getErrors();702 $numErrors = $file->getErrorCount();703 $warnings = $file->getWarnings();704 $numWarnings = $file->getWarningCount();705 $this->assertEquals(0, $numErrors);706 $this->assertCount(0, $errors);707 $this->assertEquals(1, $numWarnings);708 $this->assertCount(1, $warnings);709 }//end testDisableSelected()710 /**711 * Test re-enabling specific sniffs that have been disabled.712 *713 * @return void714 */715 public function testEnableSelected()716 {717 $config = new Config();718 $config->standards = ['Generic'];719 $config->sniffs = [720 'Generic.PHP.LowerCaseConstant',721 'Generic.Commenting.Todo',722 ];723 $ruleset = new Ruleset($config);724 // Suppress a single sniff and re-enable.725 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code';726 $file = new DummyFile($content, $ruleset, $config);727 $file->process();728 $errors = $file->getErrors();729 $numErrors = $file->getErrorCount();730 $warnings = $file->getWarnings();731 $numWarnings = $file->getWarningCount();732 $this->assertEquals(1, $numErrors);733 $this->assertCount(1, $errors);734 $this->assertEquals(1, $numWarnings);735 $this->assertCount(1, $warnings);736 // Suppress multiple sniffs and re-enable.737 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;';738 $file = new DummyFile($content, $ruleset, $config);739 $file->process();740 $errors = $file->getErrors();741 $numErrors = $file->getErrorCount();742 $warnings = $file->getWarnings();743 $numWarnings = $file->getWarningCount();744 $this->assertEquals(1, $numErrors);745 $this->assertCount(1, $errors);746 $this->assertEquals(1, $numWarnings);747 $this->assertCount(1, $warnings);748 // Suppress multiple sniffs and re-enable one.749 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;';750 $file = new DummyFile($content, $ruleset, $config);751 $file->process();752 $errors = $file->getErrors();753 $numErrors = $file->getErrorCount();754 $warnings = $file->getWarnings();755 $numWarnings = $file->getWarningCount();756 $this->assertEquals(0, $numErrors);757 $this->assertCount(0, $errors);758 $this->assertEquals(1, $numWarnings);759 $this->assertCount(1, $warnings);760 // Suppress a category of sniffs and re-enable.761 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting'.PHP_EOL.'//TODO: write some code';762 $file = new DummyFile($content, $ruleset, $config);763 $file->process();764 $errors = $file->getErrors();765 $numErrors = $file->getErrorCount();766 $warnings = $file->getWarnings();767 $numWarnings = $file->getWarningCount();768 $this->assertEquals(1, $numErrors);769 $this->assertCount(1, $errors);770 $this->assertEquals(1, $numWarnings);771 $this->assertCount(1, $warnings);772 // Suppress a whole standard and re-enable.773 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic'.PHP_EOL.'//TODO: write some code';774 $file = new DummyFile($content, $ruleset, $config);775 $file->process();776 $errors = $file->getErrors();777 $numErrors = $file->getErrorCount();778 $warnings = $file->getWarnings();779 $numWarnings = $file->getWarningCount();780 $this->assertEquals(0, $numErrors);781 $this->assertCount(0, $errors);782 $this->assertEquals(1, $numWarnings);783 $this->assertCount(1, $warnings);784 // Suppress a whole standard and re-enable a category.785 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting'.PHP_EOL.'//TODO: write some code';786 $file = new DummyFile($content, $ruleset, $config);787 $file->process();788 $errors = $file->getErrors();789 $numErrors = $file->getErrorCount();790 $warnings = $file->getWarnings();791 $numWarnings = $file->getWarningCount();792 $this->assertEquals(0, $numErrors);793 $this->assertCount(0, $errors);794 $this->assertEquals(1, $numWarnings);795 $this->assertCount(1, $warnings);796 // Suppress a category and re-enable a whole standard.797 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic'.PHP_EOL.'//TODO: write some code';798 $file = new DummyFile($content, $ruleset, $config);799 $file->process();800 $errors = $file->getErrors();801 $numErrors = $file->getErrorCount();802 $warnings = $file->getWarnings();803 $numWarnings = $file->getWarningCount();804 $this->assertEquals(1, $numErrors);805 $this->assertCount(1, $errors);806 $this->assertEquals(1, $numWarnings);807 $this->assertCount(1, $warnings);808 // Suppress a sniff and re-enable a category.809 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting'.PHP_EOL.'//TODO: write some code';810 $file = new DummyFile($content, $ruleset, $config);811 $file->process();812 $errors = $file->getErrors();813 $numErrors = $file->getErrorCount();814 $warnings = $file->getWarnings();815 $numWarnings = $file->getWarningCount();816 $this->assertEquals(1, $numErrors);817 $this->assertCount(1, $errors);818 $this->assertEquals(1, $numWarnings);819 $this->assertCount(1, $warnings);820 // Suppress a whole standard and re-enable a sniff.821 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code';822 $file = new DummyFile($content, $ruleset, $config);823 $file->process();824 $errors = $file->getErrors();825 $numErrors = $file->getErrorCount();826 $warnings = $file->getWarnings();827 $numWarnings = $file->getWarningCount();828 $this->assertEquals(0, $numErrors);829 $this->assertCount(0, $errors);830 $this->assertEquals(1, $numWarnings);831 $this->assertCount(1, $warnings);832 // Suppress a whole standard and re-enable and re-disable a sniff.833 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable'.PHP_EOL.'//TODO: write some code';834 $file = new DummyFile($content, $ruleset, $config);835 $file->process();836 $errors = $file->getErrors();837 $numErrors = $file->getErrorCount();838 $warnings = $file->getWarnings();839 $numWarnings = $file->getWarningCount();840 $this->assertEquals(0, $numErrors);841 $this->assertCount(0, $errors);842 $this->assertEquals(2, $numWarnings);843 $this->assertCount(2, $warnings);844 // Suppress a whole standard and re-enable 2 specific sniffs independently.845 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// phpcs:enable Generic.PHP.LowerCaseConstant'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;'.PHP_EOL;846 $file = new DummyFile($content, $ruleset, $config);847 $file->process();848 $errors = $file->getErrors();849 $numErrors = $file->getErrorCount();850 $warnings = $file->getWarnings();851 $numWarnings = $file->getWarningCount();852 $this->assertEquals(1, $numErrors);853 $this->assertCount(1, $errors);854 $this->assertEquals(2, $numWarnings);855 $this->assertCount(2, $warnings);856 }//end testEnableSelected()857 /**858 * Test ignoring specific sniffs.859 *860 * @return void861 */862 public function testIgnoreSelected()863 {864 $config = new Config();865 $config->standards = ['Generic'];866 $config->sniffs = [867 'Generic.PHP.LowerCaseConstant',868 'Generic.Commenting.Todo',869 ];870 $ruleset = new Ruleset($config);871 // No suppression.872 $content = '<?php '.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code';873 $file = new DummyFile($content, $ruleset, $config);874 $file->process();875 $errors = $file->getErrors();876 $numErrors = $file->getErrorCount();877 $warnings = $file->getWarnings();878 $numWarnings = $file->getWarningCount();879 $this->assertEquals(2, $numErrors);880 $this->assertCount(2, $errors);881 $this->assertEquals(2, $numWarnings);882 $this->assertCount(2, $warnings);883 // Suppress a single sniff.884 $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code';885 $file = new DummyFile($content, $ruleset, $config);886 $file->process();887 $errors = $file->getErrors();888 $numErrors = $file->getErrorCount();889 $warnings = $file->getWarnings();890 $numWarnings = $file->getWarningCount();891 $this->assertEquals(2, $numErrors);892 $this->assertCount(2, $errors);893 $this->assertEquals(1, $numWarnings);894 $this->assertCount(1, $warnings);895 // Suppress multiple sniffs.896 $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code';897 $file = new DummyFile($content, $ruleset, $config);898 $file->process();899 $errors = $file->getErrors();900 $numErrors = $file->getErrorCount();901 $warnings = $file->getWarnings();902 $numWarnings = $file->getWarningCount();903 $this->assertEquals(1, $numErrors);904 $this->assertCount(1, $errors);905 $this->assertEquals(1, $numWarnings);906 $this->assertCount(1, $warnings);907 // Add to suppression.908 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'// phpcs:ignore Generic.PHP.LowerCaseConstant'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code';909 $file = new DummyFile($content, $ruleset, $config);910 $file->process();911 $errors = $file->getErrors();912 $numErrors = $file->getErrorCount();913 $warnings = $file->getWarnings();914 $numWarnings = $file->getWarningCount();915 $this->assertEquals(1, $numErrors);916 $this->assertCount(1, $errors);917 $this->assertEquals(0, $numWarnings);918 $this->assertCount(0, $warnings);919 // Suppress a category of sniffs.920 $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic.Commenting'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code';921 $file = new DummyFile($content, $ruleset, $config);922 $file->process();923 $errors = $file->getErrors();924 $numErrors = $file->getErrorCount();925 $warnings = $file->getWarnings();926 $numWarnings = $file->getWarningCount();927 $this->assertEquals(2, $numErrors);928 $this->assertCount(2, $errors);929 $this->assertEquals(1, $numWarnings);930 $this->assertCount(1, $warnings);931 // Suppress a whole standard.932 $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code';933 $file = new DummyFile($content, $ruleset, $config);934 $file->process();935 $errors = $file->getErrors();936 $numErrors = $file->getErrorCount();937 $warnings = $file->getWarnings();938 $numWarnings = $file->getWarningCount();939 $this->assertEquals(1, $numErrors);940 $this->assertCount(1, $errors);941 $this->assertEquals(1, $numWarnings);942 $this->assertCount(1, $warnings);943 }//end testIgnoreSelected()944 /**945 * Test ignoring specific sniffs.946 *947 * @return void948 */949 public function testCommenting()950 {951 $config = new Config();952 $config->standards = ['Generic'];953 $config->sniffs = [954 'Generic.PHP.LowerCaseConstant',955 'Generic.Commenting.Todo',956 ];957 $ruleset = new Ruleset($config);958 // Suppress a single sniff.959 $content = '<?php '.PHP_EOL.'// phpcs:ignore Generic.Commenting.Todo -- Because reasons'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code';960 $file = new DummyFile($content, $ruleset, $config);961 $file->process();962 $errors = $file->getErrors();963 $numErrors = $file->getErrorCount();964 $warnings = $file->getWarnings();965 $numWarnings = $file->getWarningCount();966 $this->assertEquals(2, $numErrors);967 $this->assertCount(2, $errors);968 $this->assertEquals(1, $numWarnings);969 $this->assertCount(1, $warnings);970 // Suppress a single sniff and re-enable.971 $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo --Because reasons'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo -- Because reasons'.PHP_EOL.'//TODO: write some code';972 $file = new DummyFile($content, $ruleset, $config);973 $file->process();974 $errors = $file->getErrors();975 $numErrors = $file->getErrorCount();976 $warnings = $file->getWarnings();977 $numWarnings = $file->getWarningCount();978 $this->assertEquals(1, $numErrors);979 $this->assertCount(1, $errors);980 $this->assertEquals(1, $numWarnings);981 $this->assertCount(1, $warnings);982 // Suppress a single sniff using block comments.983 $content = '<?php '.PHP_EOL.'/*'.PHP_EOL.' Disable some checks'.PHP_EOL.' phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'*/'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code';984 $file = new DummyFile($content, $ruleset, $config);985 $file->process();986 $errors = $file->getErrors();987 $numErrors = $file->getErrorCount();988 $warnings = $file->getWarnings();989 $numWarnings = $file->getWarningCount();990 $this->assertEquals(1, $numErrors);991 $this->assertCount(1, $errors);992 $this->assertEquals(0, $numWarnings);993 $this->assertCount(0, $warnings);994 // Suppress a single sniff with a multi-line comment.995 $content = '<?php '.PHP_EOL.'// Turn off a check for the next line of code.'.PHP_EOL.'// phpcs:ignore Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE; //TODO: write some code'.PHP_EOL.'$var = FALSE; //TODO: write some code';996 $file = new DummyFile($content, $ruleset, $config);997 $file->process();998 $errors = $file->getErrors();999 $numErrors = $file->getErrorCount();1000 $warnings = $file->getWarnings();1001 $numWarnings = $file->getWarningCount();1002 $this->assertEquals(2, $numErrors);1003 $this->assertCount(2, $errors);1004 $this->assertEquals(1, $numWarnings);1005 $this->assertCount(1, $warnings);1006 // Ignore an enable before a disable.1007 $content = '<?php '.PHP_EOL.'// phpcs:enable Generic.PHP.NoSilencedErrors -- Because reasons'.PHP_EOL.'$var = @delete( $filename );'.PHP_EOL;1008 $file = new DummyFile($content, $ruleset, $config);1009 $file->process();1010 $errors = $file->getErrors();1011 $numErrors = $file->getErrorCount();1012 $warnings = $file->getWarnings();1013 $numWarnings = $file->getWarningCount();1014 $this->assertEquals(0, $numErrors);1015 $this->assertCount(0, $errors);1016 $this->assertEquals(0, $numWarnings);1017 $this->assertCount(0, $warnings);1018 }//end testCommenting()1019}//end class...

Full Screen

Full Screen

eol

Using AI Code Generation

copy

Full Screen

1require_once 'vendor/autoload.php';2use mageekguy\atoum\writers\std;3use mageekguy\atoum\writers\file;4use mageekguy\atoum\report\fields\runner\result\cli;5use mageekguy\atoum\report\fields\runner\result\cli\colorizer;6use mageekguy\atoum\report\fields\runner\result\cli\colorizer\theme;7use mageekguy\atoum\report\fields\runner\failures\cli\colorizer\theme as failureTheme;8use mageekguy\atoum\report\fields\runner\outputs\cli\colorizer\theme as outputTheme;9use mageekguy\atoum\report\fields\runner\exceptions\cli\colorizer\theme as exceptionTheme;10use mageekguy\atoum\report\fields\runner\errors\cli\colorizer\theme as errorTheme;11use mageekguy\atoum\report\fields\runner\tests\cli\colorizer\theme as testTheme;12use mageekguy\atoum\report\fields\runner\void\cli\colorizer\theme as voidTheme;13use mageekguy\atoum\report\fields\runner\uncompleted\cli\colorizer\theme as uncompletedTheme;14use mageekguy\atoum\report\fields\runner\skipped\cli\colorizer\theme as skippedTheme;15use mageekguy\atoum\report\fields\runner\duration\cli\colorizer\theme as durationTheme;16use mageekguy\atoum\report\fields\runner\memory\cli\colorizer\theme as memoryTheme;17use mageekguy\atoum\report\fields\runner\coverage\cli\colorizer\theme as coverageTheme;18use mageekguy\atoum\report\fields\runner\failures\cli;19use mageekguy\atoum\report\fields\runner\outputs\cli;20use mageekguy\atoum\report\fields\runner\exceptions\cli;21use mageekguy\atoum\report\fields\runner\errors\cli;

Full Screen

Full Screen

eol

Using AI Code Generation

copy

Full Screen

1use mageekguy\atoum\report\fields\runner\result\eol as eol;2use mageekguy\atoum\report\fields\runner\result\eol as eol;3use mageekguy\atoum\report\fields\runner\result\eol as eol;4use mageekguy\atoum\report\fields\runner\result\eol as eol;5use mageekguy\atoum\report\fields\runner\result\eol as eol;6use mageekguy\atoum\report\fields\runner\result\eol as eol;7use mageekguy\atoum\report\fields\runner\result\eol as eol;8use mageekguy\atoum\report\fields\runner\result\eol as eol;9use mageekguy\atoum\report\fields\runner\result\eol as eol;10use mageekguy\atoum\report\fields\runner\result\eol as eol;11use mageekguy\atoum\report\fields\runner\result\eol as eol;12use mageekguy\atoum\report\fields\runner\result\eol as eol;

Full Screen

Full Screen

eol

Using AI Code Generation

copy

Full Screen

1$eol = new \mageekguy\atoum\tools\variable\analyzer\eol();2$analyzer = new \mageekguy\atoum\tools\variable\analyzer();3$analyzer->addAnalyzer($eol);4$variable = new \mageekguy\atoum\tools\variable();5$variable->setAnalyzer($analyzer);6$asserter = new \mageekguy\atoum\asserters\variable($variable);7$asserter->setWith($eol);8$asserter->hasSameEolAs($eol);9$asserter->hasSameEolAs("\r10");11$asserter->hasSameEolAs("\r");12$asserter->hasSameEolAs("13");14$asserter->hasSameEolAs("\r15")->not();16$asserter->hasSameEolAs("\r")->not();17$asserter->hasSameEolAs("18")->not();19$asserter->hasSameEolAs("\r20")->not();21$asserter->hasSameEolAs("\r")->not();22$asserter->hasSameEolAs("23")->not();24$asserter->hasSameEolAs("\r25");26$asserter->hasSameEolAs("\r");27$asserter->hasSameEolAs("28");

Full Screen

Full Screen

eol

Using AI Code Generation

copy

Full Screen

1$php = new \mageekguy\atoum\php\engine();2$php->addDefaultReport();3$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\colorizer());4$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\progressBar());5$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\prompt());6$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\report());7$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\runner());8$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test());9$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\duration());10$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\duration\bar());11$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\duration\progressBar());12$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\failures());13$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\memory());14$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\memory\bar());15$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\memory\progressBar());16$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\method());17$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\methods());18$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\runDuration());19$php->addExtension(new \mageekguy\atoum\reports\realtime\cli\test\runDuration\bar());20$php->addExtension(new \mageek

Full Screen

Full Screen

eol

Using AI Code Generation

copy

Full Screen

1use mageekguy\atoum;2{3 public function testEol()4 {5 ->given($eol = new atoum\writers\std\out\eol())6 ->string($eol->write())->isEqualTo(PHP_EOL)7 ;8 }9}10use mageekguy\atoum;11{12 public function testEol()13 {14 ->given($eol = new atoum\writers\std\out\eol())15 ->string($eol->write())->isEqualTo(PHP_EOL)16 ;17 }18}19use mageekguy\atoum;20{21 public function testEol()22 {23 ->given($eol = new atoum\writers\std\out\eol())24 ->string($eol->write())->isEqualTo(PHP_EOL)25 ;26 }27}28use mageekguy\atoum;29{30 public function testEol()31 {32 ->given($eol = new atoum\writers\std\out\eol())33 ->string($eol->write())->isEqualTo(PHP_EOL)34 ;35 }36}37use mageekguy\atoum;38{39 public function testEol()40 {41 ->given($eol = new atoum\writers\std\out\eol())42 ->string($eol->write())->isEqualTo(PHP_EOL)43 ;44 }45}46use mageekguy\atoum;

Full Screen

Full Screen

eol

Using AI Code Generation

copy

Full Screen

1{2 public function testEol()3 {4 ->given($eol = new \eol())5 ->string($eol->getEol())6 ->isEqualTo(PHP_EOL)7 ;8 }9}

Full Screen

Full Screen

eol

Using AI Code Generation

copy

Full Screen

1use \mageekguy\atoum;2{3 public function testEol()4 {5 $this->variable($this->eol)->isEqualTo(PHP_EOL);6 }7}8use \mageekguy\atoum;9{10 public function testEol()11 {12 $this->variable($this->eol)->isEqualTo(PHP_EOL);13 }14}15use \mageekguy\atoum;16{17 public function testEol()18 {19 $this->variable($this->eol)->isEqualTo(PHP_EOL);20 }21}22use \mageekguy\atoum;23{24 public function testEol()25 {26 $this->variable($this->eol)->isEqualTo(PHP_EOL);27 }28}29use \mageekguy\atoum;30{31 public function testEol()32 {33 $this->variable($this->eol)->isEqualTo(PHP_EOL);34 }35}36use \mageekguy\atoum;37{38 public function testEol()39 {40 $this->variable($this->eol)->isEqualTo(PHP_EOL);41 }42}43use \mageekguy\atoum;44{45 public function testEol()46 {47 $this->variable($this->eol)->isEqualTo(PHP_EOL);48 }49}50use \mageekguy\atoum;51{52 public function testEol()

Full Screen

Full Screen

eol

Using AI Code Generation

copy

Full Screen

1use EOL\Atoum;2use EOL\PHPUnit;3{4 public function testEOL()5 {6 $this->string("Hello World")->hasEOL();7 $this->string("Hello World")->hasNoEOL();8 $this->string("Hello World9")->hasEOL();10 $this->string("Hello World11")->hasEOL(EOL::LF);12 $this->string("Hello World13")->hasEOL(EOL::CRLF);14 $this->string("Hello World15")->hasEOL(EOL::CR);16 $this->string("Hello World17")->hasEOL(EOL::CR, EOL::LF);18 $this->string("Hello World19")->hasEOL(EOL::LF, EOL::CR);20 $this->string("Hello World21")->hasEOL(EOL::CR, EOL::LF, EOL::CR);22 $this->string("Hello World23")->hasEOL(EOL::LF, EOL::CR, EOL::LF);24 $this->string("Hello World25")->hasNoEOL(EOL::CR);26 $this->string("Hello World27")->hasNoEOL(EOL::LF);28 $this->string("Hello World29")->hasNoEOL(EOL::CRLF);30 $this->string("Hello World31")->hasNoEOL(EOL::CR, EOL::LF);32 $this->string("Hello World33")->hasNoEOL(EOL::LF, EOL::CR);34 $this->string("Hello World35")->hasNoEOL(EOL::CR, EOL::LF, EOL::CR);36 $this->string("Hello World37")->hasNoEOL(EOL::LF, EOL::CR, EOL::LF);38 }39}40use EOL\Atoum;41use EOL\PHPUnit;42{43 public function testEOL()44 {45 $this->assertThat("Hello World", new E

Full Screen

Full Screen

eol

Using AI Code Generation

copy

Full Screen

1$eol = new \mageekguy\atoum\cli\prompt\colorizer\eol();2$eol->setEol("\r3");4$eol = new \mageekguy\atoum\cli\prompt\colorizer\eol();5$eol->setEol("\r6");7$eol = new \mageekguy\atoum\cli\prompt\colorizer\eol();8$eol->setEol("\r9");10$eol = new \mageekguy\atoum\cli\prompt\colorizer\eol();11$eol->setEol("\r12");13$eol = new \mageekguy\atoum\cli\prompt\colorizer\eol();14$eol->setEol("\r15");16$eol = new \mageekguy\atoum\cli\prompt\colorizer\eol();17$eol->setEol("\r18");19$eol = new \mageekguy\atoum\cli\prompt\colorizer\eol();20$eol->setEol("\r21");22$eol = new \mageekguy\atoum\cli\prompt\colorizer\eol();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in eol

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful