diff --git a/.travis.yml b/.travis.yml
index 74e374412fff4..6c147707b3342 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,12 +26,11 @@ cache:
directories: $HOME/.composer/cache
matrix:
exclude:
- - php: 7.0
+ - php: 5.6.29
env: TEST_SUITE=static
before_install: ./dev/travis/before_install.sh
install: composer install --no-interaction --prefer-dist
before_script: ./dev/travis/before_script.sh
script:
- - cd dev/tests/$TEST_SUITE
- test $TEST_SUITE = "static" && TEST_FILTER='--filter "Magento\\Test\\Php\\LiveCodeTest"' || true
- - phpunit $TEST_FILTER
+ - phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER
diff --git a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php
index eba745bfe2da9..d0b9868796be8 100644
--- a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php
+++ b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php
@@ -40,7 +40,7 @@ class CodeSniffer implements ToolInterface, ExtensionInterface
*
* @var array
*/
- private $extensions = ['php'];
+ private $extensions = ['php', 'phtml'];
/**
* Constructor
@@ -51,8 +51,11 @@ class CodeSniffer implements ToolInterface, ExtensionInterface
*/
public function __construct($rulesetDir, $reportFile, Wrapper $wrapper)
{
- $this->reportFile = $reportFile;
$this->rulesetDir = $rulesetDir;
+ if (!file_exists($rulesetDir) && file_exists($fullPath = realpath(__DIR__ . '/../../../../' . $rulesetDir))) {
+ $this->rulesetDir = $fullPath;
+ }
+ $this->reportFile = $reportFile;
$this->wrapper = $wrapper;
}
diff --git a/dev/tests/static/framework/Magento/ruleset.xml b/dev/tests/static/framework/Magento/ruleset.xml
index a636b13c7ff99..d877eb17104d4 100644
--- a/dev/tests/static/framework/Magento/ruleset.xml
+++ b/dev/tests/static/framework/Magento/ruleset.xml
@@ -7,6 +7,9 @@
-->
Custom Magento coding standard.
+
+
+
@@ -16,4 +19,11 @@
*/_files/*
+
+
+
+
+
+
+
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
index 036805558830f..2dcf36a4087ee 100644
--- a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
@@ -189,101 +189,27 @@ function ($file) use ($fileHasAllowedType, $fileIsInAllowedDirectory) {
}
/**
- * Run the PSR2 code sniffs on the code
+ * Retrieves full list of codebase paths without any files/folders filtered out
*
- * @TODO: combine with testCodeStyle
- * @return void
+ * @return array
*/
- public function testCodeStylePsr2()
+ private function getFullWhitelist()
{
- $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
- );
+ return Files::init()->readLists(__DIR__ . '/_files/whitelist/common.txt');
}
- /**
- * Run the magento specific coding standards on the code
- *
- * @return void
- */
- public function testCodeStyle()
+ public function testNoViolationsDetectedByPhpCodeSniffer()
{
$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.');
- }
- $codeSniffer->setExtensions(['php', 'phtml']);
- $result = $codeSniffer->run(self::getWhitelist(['php', 'phtml']));
-
- $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 annotations sniffs on the code
- *
- * @return void
- * @todo Combine with normal code style at some point.
- */
- public function testAnnotationStandard()
- {
- $reportFile = self::$reportDir . '/phpcs_annotations_report.txt';
- $wrapper = new Wrapper();
- $codeSniffer = new CodeSniffer(
- realpath(__DIR__ . '/../../../../framework/Magento/ruleset.xml'),
- $reportFile,
- $wrapper
- );
- if (!$codeSniffer->canRun()) {
- $this->markTestSkipped('PHP Code Sniffer is not installed.');
- }
-
- $result = $codeSniffer->run(self::getWhitelist(['php']));
- $output = "";
- if (file_exists($reportFile)) {
- $output = file_get_contents($reportFile);
- }
+ $codeSniffer = new CodeSniffer('Magento', $reportFile, new Wrapper());
$this->assertEquals(
0,
- $result,
- "PHP Code Sniffer has found {$result} error(s): " . PHP_EOL . $output
+ $result = $codeSniffer->run($this->getFullWhitelist()),
+ "PHP Code Sniffer detected {$result} violation(s): " . PHP_EOL . file_get_contents($reportFile)
);
}
- /**
- * Run mess detector on code
- *
- * @return void
- */
- public function testCodeMess()
+ public function testNoViolationsDetectedByPhpMessDetector()
{
$reportFile = self::$reportDir . '/phpmd_report.txt';
$codeMessDetector = new CodeMessDetector(realpath(__DIR__ . '/_files/phpmd/ruleset.xml'), $reportFile);
@@ -312,12 +238,7 @@ public function testCodeMess()
}
}
- /**
- * Run copy paste detector on code
- *
- * @return void
- */
- public function testCopyPaste()
+ public function testNoViolationsDetectedByPhpCopyPasteDetector()
{
$reportFile = self::$reportDir . '/phpcpd_report.xml';
$copyPasteDetector = new CopyPasteDetector($reportFile);
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/ruleset.xml b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/ruleset.xml
deleted file mode 100644
index 8a3a701c15feb..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/ruleset.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
- Magento coding standard.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
index e5c31e5afcb0c..8e1e6f16bc351 100644
--- a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
@@ -1,8 +1,7 @@
-module * /
-library * /
-dev/tools/Magento
-dev/tests/api-functional
-dev/tests/functional
-dev/tests/integration
-dev/tests/static
-setup
\ No newline at end of file
+# Format: or simply
+* * /
+dev
+phpserver
+pub
+setup
+*.php