Closed
Description
Preconditions
- Use fix from #6: Fix line length sniff when using translations #74 (original implementation of the sniff is broken)
Steps to reproduce
-
in
Magento2/Tests/Files/LineLengthUnitTest.inc
, add this line:$test = "If a string exceeds 120 characters and a part of the string is Phrase('xy'), this would not be caught by the regular expression because it matches any line containing Phrase('xy') or __('xy').";
-
Run
vendor/bin/phpunit
Expected result
-
An error as the line contains no translation but only the keywords "Phrase" and "__" inside a string, e.g.
PHPUnit 5.7.27 by Sebastian Bergmann and contributors. ..........F.................... 31 / 31 (100%) Time: 441 ms, Memory: 14.00MB There was 1 failure: 1) Magento2\Tests\Files\LineLengthUnitTest::testSniff [LINE 32] Expected 0 error(s) in LineLengthUnitTest.inc but found 1 error(s). The error(s) found were: -> Line exceeds maximum limit of 120 characters; contains 202 characters (Magento2.Files.LineLength.MaxExceeded) /home/matthias/PhpstormProjects/magento-coding-standard/vendor/squizlabs/php_codesniffer/tests/Standards/AbstractSniffUnitTest.php:205 FAILURES! Tests: 31, Assertions: 0, Failures: 1.
Actual result
-
The long string is missed:
PHPUnit 5.7.27 by Sebastian Bergmann and contributors. ............................... 31 / 31 (100%) Time: 519 ms, Memory: 14.00MB OK (31 tests, 0 assertions)