Skip to content

Commit 34effb0

Browse files
committed
AC-1194: Update tags
- add ability to run "full" scan - increase report line length to fit file path
1 parent f5eba53 commit 34effb0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function run(array $whiteList)
9999
$settings['standards'] = [$this->rulesetDir];
100100
$settings['extensions'] = $this->extensions;
101101
$settings['reports']['full'] = $this->reportFile;
102+
$settings['reportWidth'] = 120;
102103
$this->wrapper->setSettings($settings);
103104

104105
// phpcs:ignore Magento2.Functions.DiscouragedFunction

dev/tests/static/testsuite/Magento/Test/Html/LiveCodeTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Test\Html;
88

9+
use Magento\Framework\App\Utility\Files;
910
use Magento\TestFramework\CodingStandard\Tool\CodeSniffer;
1011
use Magento\Test\Php\LiveCodeTest as PHPCodeTest;
1112
use Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper;
@@ -46,12 +47,33 @@ public function testCodeStyle(): void
4647
$reportFile = self::$reportDir . '/html_report.txt';
4748
$codeSniffer = new CodeSniffer('Magento', $reportFile, new Wrapper());
4849
$codeSniffer->setExtensions([self::FILE_EXTENSION]);
49-
$result = $codeSniffer->run(PHPCodeTest::getWhitelist([self::FILE_EXTENSION], __DIR__, __DIR__));
50+
$fileList = $this->isFullScan() ? array_column(Files::init()->getStaticHtmlFiles(), '0')
51+
: PHPCodeTest::getWhitelist([self::FILE_EXTENSION], __DIR__, __DIR__);
52+
$result = $codeSniffer->run($fileList);
5053
$report = file_exists($reportFile) ? file_get_contents($reportFile) : '';
5154
$this->assertEquals(
5255
0,
5356
$result,
5457
"PHP Code Sniffer detected {$result} violation(s): " . PHP_EOL . $report
5558
);
5659
}
60+
61+
/**
62+
* Returns whether a full scan was requested.
63+
*
64+
* This can be set in the `phpunit.xml` used to run these test cases, by setting the constant
65+
* `TESTCODESTYLE_IS_FULL_SCAN` to `1`, e.g.:
66+
* ```xml
67+
* <php>
68+
* <!-- TESTCODESTYLE_IS_FULL_SCAN - specify if full scan should be performed for test code style test -->
69+
* <const name="TESTCODESTYLE_IS_FULL_SCAN" value="0"/>
70+
* </php>
71+
* ```
72+
*
73+
* @return bool
74+
*/
75+
private function isFullScan(): bool
76+
{
77+
return defined('TESTCODESTYLE_IS_FULL_SCAN') && TESTCODESTYLE_IS_FULL_SCAN === '1';
78+
}
5779
}

0 commit comments

Comments
 (0)