Skip to content

Commit 0b6fe4b

Browse files
committed
AC-943: Create unit test for Magento2\Less\ColourDefinitionSniff check
1 parent e83a012 commit 0b6fe4b

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

Magento2/Sniffs/Less/ColourDefinitionSniff.php

Lines changed: 1 addition & 1 deletion
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('Hexadecimal value should be get from a variable', $stackPtr, 'NotInVariable');
4646
}
4747

4848
$expected = strtolower($colour);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
10+
.my{
11+
color: @red;
12+
}
13+
14+
.foo {
15+
color: #aaa;
16+
}
17+
18+
.baz {
19+
color: @blue;
20+
}
21+
22+
.bar {
23+
color: @green;
24+
}
Lines changed: 29 additions & 0 deletions
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+
15 => 1,
19+
];
20+
}
21+
22+
/**
23+
* @inheritdoc
24+
*/
25+
public function getWarningList()
26+
{
27+
return [];
28+
}
29+
}

0 commit comments

Comments
 (0)