Skip to content

Combined testCodeStylePsr2() with the testCodeStyle() function. #7496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 6 additions & 31 deletions dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,6 @@ function ($path) use ($directoriesToCheck, $fileTypes) {
return $changedFiles;
}

/**
* Run the PSR2 code sniffs on the code
*
* @TODO: combine with testCodeStyle
* @return void
*/
public function testCodeStylePsr2()
{
$reportFile = self::$reportDir . '/phpcs_psr2_report.txt';
$wrapper = new Wrapper();
$codeSniffer = new CodeSniffer('PSR2', $reportFile, $wrapper);
if (!$codeSniffer->canRun()) {
$this->markTestSkipped('PHP Code Sniffer is not installed.');
}
if (version_compare($wrapper->version(), '1.4.7') === -1) {
$this->markTestSkipped('PHP Code Sniffer Build Too Old.');
}

$result = $codeSniffer->run(self::getWhitelist());

$output = "";
if (file_exists($reportFile)) {
$output = file_get_contents($reportFile);
}
$this->assertEquals(
0,
$result,
"PHP Code Sniffer has found {$result} error(s): " . PHP_EOL . $output
);
}

/**
* Run the magento specific coding standards on the code
*
Expand All @@ -155,9 +124,15 @@ public function testCodeStyle()
$reportFile = self::$reportDir . '/phpcs_report.txt';
$wrapper = new Wrapper();
$codeSniffer = new CodeSniffer(realpath(__DIR__ . '/_files/phpcs'), $reportFile, $wrapper);

if (!$codeSniffer->canRun()) {
$this->markTestSkipped('PHP Code Sniffer is not installed.');
}

if (version_compare($wrapper->version(), '1.4.7') === -1) {
$this->markTestSkipped('PHP Code Sniffer Build Too Old.');
}

$codeSniffer->setExtensions(['php', 'phtml']);
$result = $codeSniffer->run(self::getWhitelist(['php', 'phtml']));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
-->
<ruleset name="Magento">
<description>Magento coding standard.</description>
<!-- We don't want to test stub file for unit testing -->
<exclude-pattern>*/_files/*</exclude-pattern>
<rule ref="PSR2"/>
<rule ref="Zend.Files.ClosingTag"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
Expand Down