Skip to content

Commit 4c366f4

Browse files
authored
Merge pull request #48 from magento-commerce/imported-magento-magento-coding-standard-238
[Imported] AC-943: Create unit test for Magento2\Less\ColourDefinitionSniff check
2 parents 4406251 + 33d3196 commit 4c366f4

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

Magento2/Sniffs/Less/ColourDefinitionSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function process(File $phpcsFile, $stackPtr)
4242

4343
$variablePtr = $phpcsFile->findPrevious(T_ASPERAND, $stackPtr);
4444
if ((false === $variablePtr) || ($tokens[$stackPtr]['line'] !== $tokens[$variablePtr]['line'])) {
45-
$phpcsFile->addError('Hexadecimal value should be used for variable', $stackPtr, 'NotInVariable');
45+
$phpcsFile->addError('A variable should be used for a CSS colour', $stackPtr, 'NotInVariable');
4646
}
4747

4848
$expected = strtolower($colour);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// /**
2+
// * Copyright © Magento, Inc. All rights reserved.
3+
// * See COPYING.txt for license details.
4+
// */
5+
6+
@red: #aaaaaa;
7+
@blue: #00F;
8+
@green: #0f0;
9+
@purple: #abcdef;
10+
11+
.my{
12+
color: @red;
13+
}
14+
15+
.foo {
16+
color: #aaa;
17+
}
18+
19+
.baz {
20+
color: @blue;
21+
}
22+
23+
.bar {
24+
color: @green;
25+
}
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 ColourDefinitionUnitTest extends AbstractLessSniffUnitTestCase
9+
{
10+
/**
11+
* @inheritdoc
12+
*/
13+
public function getErrorList()
14+
{
15+
return [
16+
6 => 1,
17+
7 => 1,
18+
16 => 1,
19+
];
20+
}
21+
22+
/**
23+
* @inheritdoc
24+
*/
25+
public function getWarningList()
26+
{
27+
return [];
28+
}
29+
}

0 commit comments

Comments
 (0)