From a16e77e80849a42e7cec98610e8a39897b0e4789 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Wed, 1 Sep 2021 12:54:15 +0200 Subject: [PATCH] AC-956: Create unit test for Magento2\Less\ZeroUnitsSniff check --- Magento2/Sniffs/Less/ZeroUnitsSniff.php | 2 +- Magento2/Tests/Less/ZeroUnitsUnitTest.less | 14 +++++++++++ Magento2/Tests/Less/ZeroUnitsUnitTest.php | 28 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 Magento2/Tests/Less/ZeroUnitsUnitTest.less create mode 100644 Magento2/Tests/Less/ZeroUnitsUnitTest.php diff --git a/Magento2/Sniffs/Less/ZeroUnitsSniff.php b/Magento2/Sniffs/Less/ZeroUnitsSniff.php index 51971c78..05b26327 100644 --- a/Magento2/Sniffs/Less/ZeroUnitsSniff.php +++ b/Magento2/Sniffs/Less/ZeroUnitsSniff.php @@ -14,7 +14,7 @@ * Ensure that units for 0 is not specified * Omit leading "0"s in values, use dot instead * - * @link https://devdocs.magento.com/guides/v2.4/coding-standards/code-standard-less.html#and-units + * @link https://devdocs.magento.com/guides/v2.4/coding-standards/code-standard-less.html#0-and-units * @link https://devdocs.magento.com/guides/v2.4/coding-standards/code-standard-less.html#floating-values */ class ZeroUnitsSniff implements Sniff diff --git a/Magento2/Tests/Less/ZeroUnitsUnitTest.less b/Magento2/Tests/Less/ZeroUnitsUnitTest.less new file mode 100644 index 00000000..dcb794ad --- /dev/null +++ b/Magento2/Tests/Less/ZeroUnitsUnitTest.less @@ -0,0 +1,14 @@ +// /** +// * Copyright © Magento, Inc. All rights reserved. +// * See COPYING.txt for license details. +// */ + +.my{ + border-width: 0px; + margin-left: 0.5rem; +} + +.foo { + border-width: 0; + margin-left: .5rem; +} diff --git a/Magento2/Tests/Less/ZeroUnitsUnitTest.php b/Magento2/Tests/Less/ZeroUnitsUnitTest.php new file mode 100644 index 00000000..96c0d028 --- /dev/null +++ b/Magento2/Tests/Less/ZeroUnitsUnitTest.php @@ -0,0 +1,28 @@ + 1, + 8 => 1, + ]; + } + + /** + * @inheritdoc + */ + public function getWarningList() + { + return []; + } +}