Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions
LiveCodeTest Class Reference
Inheritance diagram for LiveCodeTest:

Public Member Functions

 testCodeStyle ()
 

Static Public Member Functions

static setUpBeforeClass ()
 

Detailed Description

Set of tests for static code style

Definition at line 18 of file LiveCodeTest.php.

Member Function Documentation

◆ setUpBeforeClass()

static setUpBeforeClass ( )
static

Setup basics for all tests

Returns
void

Definition at line 30 of file LiveCodeTest.php.

31  {
32  self::$reportDir = BP . '/dev/tests/static/report';
33  if (!is_dir(self::$reportDir)) {
34  mkdir(self::$reportDir, 0770);
35  }
36  }
const BP
Definition: autoload.php:14
mkdir($pathname, $mode=0777, $recursive=false, $context=null)
Definition: ioMock.php:25

◆ testCodeStyle()

testCodeStyle ( )

Run the magento specific coding standards on the code

Returns
void

Definition at line 43 of file LiveCodeTest.php.

44  {
45  $reportFile = self::$reportDir . '/csless_report.txt';
46  $wrapper = new LessWrapper();
47  $codeSniffer = new CodeSniffer(realpath(__DIR__ . '/_files/lesscs'), $reportFile, $wrapper);
48 
49  if (!$codeSniffer->canRun()) {
50  $this->markTestSkipped('PHP Code Sniffer is not installed.');
51  }
52 
53  $codeSniffer->setExtensions([LessWrapper::LESS_FILE_EXTENSION]);
54 
55  $fileList = PHPCodeTest::getWhitelist([LessWrapper::LESS_FILE_EXTENSION], __DIR__, __DIR__);
56 
57  $result = $codeSniffer->run($this->filterFiles($fileList));
58 
59  $report = file_exists($reportFile) ? file_get_contents($reportFile) : "";
60  $this->assertEquals(
61  0,
62  $result,
63  "PHP Code Sniffer has found {$result} error(s): " . PHP_EOL . $report
64  );
65  }
$fileList
Definition: export.php:13
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

The documentation for this class was generated from the following file: