Skip to content

Commit 86a9bcc

Browse files
Ability to use whitelist for testing code style, based on const defined in phpunit xml config file
1 parent ba4b975 commit 86a9bcc

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

dev/tests/static/phpunit-all.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@
1919
</testsuites>
2020
<php>
2121
<ini name="date.timezone" value="America/Los_Angeles"/>
22+
<!-- TESTCODESTYLE_IS_FULL_SCAN - specify if full scan should be performed for test code style test -->
23+
<const name="TESTCODESTYLE_IS_FULL_SCAN" value="1"/>
2224
</php>
2325
</phpunit>

dev/tests/static/phpunit.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
</testsuites>
3030
<php>
3131
<ini name="date.timezone" value="America/Los_Angeles"/>
32+
<!-- TESTCODESTYLE_IS_FULL_SCAN - specify if full scan should be performed for test code style test -->
33+
<const name="TESTCODESTYLE_IS_FULL_SCAN" value="1"/>
3234
<!-- TESTS_COMPOSER_PATH - specify the path to composer binary, if a relative reference cannot be resolved -->
3335
<!--<const name="TESTS_COMPOSER_PATH" value="/usr/local/bin/composer"/>-->
3436
</php>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,14 @@ private function getFullWhitelist()
201201

202202
public function testCodeStyle()
203203
{
204+
$whiteList = defined('TESTCODESTYLE_IS_FULL_SCAN') && TESTCODESTYLE_IS_FULL_SCAN === '1'
205+
? $this->getFullWhitelist() : self::getWhitelist(['php', 'phtml']);
206+
204207
$reportFile = self::$reportDir . '/phpcs_report.txt';
205208
$codeSniffer = new CodeSniffer('Magento', $reportFile, new Wrapper());
206209
$this->assertEquals(
207210
0,
208-
$result = $codeSniffer->run($this->getFullWhitelist()),
211+
$result = $codeSniffer->run($whiteList),
209212
"PHP Code Sniffer detected {$result} violation(s): " . PHP_EOL . file_get_contents($reportFile)
210213
);
211214
}

0 commit comments

Comments
 (0)