|
6 | 6 |
|
7 | 7 | namespace Magento\Test\Html; |
8 | 8 |
|
| 9 | +use Magento\Framework\App\Utility\Files; |
9 | 10 | use Magento\TestFramework\CodingStandard\Tool\CodeSniffer; |
10 | 11 | use Magento\Test\Php\LiveCodeTest as PHPCodeTest; |
11 | 12 | use Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper; |
@@ -46,12 +47,33 @@ public function testCodeStyle(): void |
46 | 47 | $reportFile = self::$reportDir . '/html_report.txt'; |
47 | 48 | $codeSniffer = new CodeSniffer('Magento', $reportFile, new Wrapper()); |
48 | 49 | $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); |
50 | 53 | $report = file_exists($reportFile) ? file_get_contents($reportFile) : ''; |
51 | 54 | $this->assertEquals( |
52 | 55 | 0, |
53 | 56 | $result, |
54 | 57 | "PHP Code Sniffer detected {$result} violation(s): " . PHP_EOL . $report |
55 | 58 | ); |
56 | 59 | } |
| 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 | + } |
57 | 79 | } |
0 commit comments