Skip to content

Commit e538e6f

Browse files
committed
AC-939: Create unit test for Magento2\Less\AvoidIdSniff check
1 parent 437cbae commit e538e6f

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento2\Tests\Less;
7+
8+
use PHP_CodeSniffer\Config;
9+
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
10+
11+
/**
12+
* Implements an abstract base for unit tests that cover less sniffs.
13+
*/
14+
abstract class AbstractLessSniffUnitTestCase extends AbstractSniffUnitTest
15+
{
16+
/**
17+
* @inheritDoc
18+
*/
19+
protected function setUp(): void
20+
{
21+
parent::setUp();
22+
23+
$config = new Config();
24+
$config->extensions = array_merge(
25+
$config->extensions,
26+
[
27+
'less' => 'CSS'
28+
]
29+
);
30+
31+
$GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config;
32+
}
33+
}

Magento2/Tests/Less/AvoidIdUnitTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
*/
66
namespace Magento2\Tests\Less;
77

8-
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
9-
10-
class AvoidIdUnitTest extends AbstractSniffUnitTest
8+
class AvoidIdUnitTest extends AbstractLessSniffUnitTestCase
119
{
1210
/**
1311
* @inheritdoc
@@ -30,7 +28,7 @@ public function getErrorList()
3028
18 => 1,
3129
19 => 1,
3230
20 => 1,
33-
21 => 3,
31+
21 => 1,
3432
22 => 1,
3533
26 => 1,
3634
27 => 1,

Magento2/ruleset.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<description>Magento Coding Standard</description>
44

55
<!-- File extensions to be checked. -->
6-
<arg name="extensions" value="php,phtml,graphqls/GraphQL,less"/>
6+
<arg name="extensions" value="php,phtml,graphqls/GraphQL,less/CSS,html/PHP"/>
77

88
<!-- Severity 10 errors: Critical code issues. -->
99
<rule ref="Generic.Functions.CallTimePassByReference">

0 commit comments

Comments
 (0)