Skip to content

AC-952: Create unit test for Magento2\Less\SemicolonSpacingSniff check #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Magento2/Sniffs/Less/SemicolonSpacingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private function validateSemicolon(File $phpcsFile, $stackPtr, array $tokens, $s
{
if ((false === $semicolonPtr || $tokens[$semicolonPtr]['line'] !== $tokens[$stackPtr]['line'])
&& (isset($tokens[$stackPtr - 1]) && !in_array($tokens[$stackPtr - 1]['code'], $this->styleCodesToSkip))
&& (T_COLON !== $tokens[$stackPtr + 1]['code'])
&& (T_COLON !== $tokens[$stackPtr]['code'])
) {
$error = 'Style definitions must end with a semicolon';
$phpcsFile->addError($error, $stackPtr, 'NotAtEnd');
Expand Down
13 changes: 13 additions & 0 deletions Magento2/Tests/Less/SemicolonSpacingUnitTest.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// /**
// * Copyright © Magento, Inc. All rights reserved.
// * See COPYING.txt for license details.
// */

.nav {
background-color: green;
}

.nav-list {
background-color: red ;
color: red
}
28 changes: 28 additions & 0 deletions Magento2/Tests/Less/SemicolonSpacingUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Copyright © Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento2\Tests\Less;

class SemicolonSpacingUnitTest extends AbstractLessSniffUnitTestCase
{
/**
* @inheritdoc
*/
public function getErrorList()
{
return [
11 => 1,
12 => 1
];
}

/**
* @inheritdoc
*/
public function getWarningList()
{
return [];
}
}