Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AvoidIdSniffTest.php
Go to the documentation of this file.
1 <?php
7 declare(strict_types=1);
8 
9 namespace Magento\Sniffs\Less;
10 
12 
13 class AvoidIdSniffTest extends \PHPUnit\Framework\TestCase
14 {
18  public function processDataProvider()
19  {
20  return [
21  [
22  'avoid-ids.less',
23  'avoid-ids-errors.txt'
24  ]
25  ];
26  }
27 
33  public function testProcess($fileUnderTest, $expectedReportFile)
34  {
35  $reportFile = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'phpcs_report.txt';
36  $wrapper = new LessWrapper();
37  $codeSniffer = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer(
38  'Magento',
39  $reportFile,
40  $wrapper
41  );
42  $codeSniffer->setExtensions([LessWrapper::LESS_FILE_EXTENSION]);
43  $result = $codeSniffer->run(
44  [__DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . $fileUnderTest]
45  );
46  // Remove the absolute path to the file from the output
47  $actual = preg_replace('/^.+\n/', '', ltrim(file_get_contents($reportFile)));
48  $expected = file_get_contents(
49  __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . $expectedReportFile
50  );
51  unlink($reportFile);
52  $this->assertEquals(1, $result);
53  $this->assertEquals($expected, $actual);
54  }
55 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
testProcess($fileUnderTest, $expectedReportFile)