Skip to content

Commit

Permalink
Ability to use whitelist for testing code style, based on const defin…
Browse files Browse the repository at this point in the history
…ed in phpunit xml config file
  • Loading branch information
adrian-martinez-interactiv4 committed Oct 13, 2017
1 parent ba4b975 commit 86a9bcc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dev/tests/static/phpunit-all.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
</testsuites>
<php>
<ini name="date.timezone" value="America/Los_Angeles"/>
<!-- TESTCODESTYLE_IS_FULL_SCAN - specify if full scan should be performed for test code style test -->
<const name="TESTCODESTYLE_IS_FULL_SCAN" value="1"/>
</php>
</phpunit>
2 changes: 2 additions & 0 deletions dev/tests/static/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
</testsuites>
<php>
<ini name="date.timezone" value="America/Los_Angeles"/>
<!-- TESTCODESTYLE_IS_FULL_SCAN - specify if full scan should be performed for test code style test -->
<const name="TESTCODESTYLE_IS_FULL_SCAN" value="1"/>
<!-- TESTS_COMPOSER_PATH - specify the path to composer binary, if a relative reference cannot be resolved -->
<!--<const name="TESTS_COMPOSER_PATH" value="/usr/local/bin/composer"/>-->
</php>
Expand Down
5 changes: 4 additions & 1 deletion dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,14 @@ private function getFullWhitelist()

public function testCodeStyle()
{
$whiteList = defined('TESTCODESTYLE_IS_FULL_SCAN') && TESTCODESTYLE_IS_FULL_SCAN === '1'
? $this->getFullWhitelist() : self::getWhitelist(['php', 'phtml']);

$reportFile = self::$reportDir . '/phpcs_report.txt';
$codeSniffer = new CodeSniffer('Magento', $reportFile, new Wrapper());
$this->assertEquals(
0,
$result = $codeSniffer->run($this->getFullWhitelist()),
$result = $codeSniffer->run($whiteList),
"PHP Code Sniffer detected {$result} violation(s): " . PHP_EOL . file_get_contents($reportFile)
);
}
Expand Down

0 comments on commit 86a9bcc

Please sign in to comment.