Skip to content

Commit e4969eb

Browse files
authored
Merge pull request #40 from magento-commerce/imported-magento-magento-coding-standard-237
[Imported] AC-942: Create unit test for Magento2\Less\ColonSpacingSniff check
2 parents d4dc9e2 + fad9a44 commit e4969eb

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

Magento2/Sniffs/Less/ColonSpacingSniff.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Class ColonSpacingSniff
1414
*
15-
* Ensure that single quotes are used
15+
* Ensure that colon spacing is right
1616
*
1717
* @link https://devdocs.magento.com/guides/v2.4/coding-standards/code-standard-less.html#properties-colon-indents
1818
*/
@@ -101,7 +101,7 @@ private function validateSpaces(File $phpcsFile, $stackPtr, array $tokens)
101101
if (false === strpos($content, $phpcsFile->eolChar)) {
102102
$length = strlen($content);
103103
if ($length !== 1) {
104-
$error = 'Expected 1 space after colon in style definition; %s found';
104+
$error = sprintf('Expected 1 space after colon in style definition; %s found', $length);
105105
$phpcsFile->addError($error, $stackPtr, 'After');
106106
}
107107
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// /**
2+
// * Copyright © Magento, Inc. All rights reserved.
3+
// * See COPYING.txt for license details.
4+
// */
5+
6+
7+
div#foo {
8+
blah:'abc';
9+
}
10+
11+
.my #foo .blah {
12+
some: 'stuff';
13+
}
14+
15+
.blah {
16+
foo :'xyz';
17+
}
18+
19+
.foo {
20+
bar:
21+
'xyz';
22+
}
23+
24+
.right {
25+
way: 'good'
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento2\Tests\Less;
7+
8+
class ColonSpacingUnitTest extends AbstractLessSniffUnitTestCase
9+
{
10+
/**
11+
* @inheritdoc
12+
*/
13+
public function getErrorList()
14+
{
15+
return [
16+
8 => 1,
17+
12 => 1,
18+
16 => 2,
19+
];
20+
}
21+
22+
/**
23+
* @inheritdoc
24+
*/
25+
public function getWarningList()
26+
{
27+
return [];
28+
}
29+
}

0 commit comments

Comments
 (0)