Skip to content

Commit 592dcfc

Browse files
committed
AC-1102: Static test to verify self-closing tags for non-void html elements
- add unit test for new sniff
1 parent 94acecd commit 592dcfc

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

Magento2/Sniffs/Html/HtmlSelfClosingTagsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr)
7575
'Avoid using self-closing tag with non-void html element'
7676
. ' - "' . $match[0] . PHP_EOL,
7777
null,
78-
'HtmlTemplates.Tag.SelfClosing'
78+
'HtmlSelfClosingNonVoidTag'
7979
);
8080
}
8181
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
8+
<html>
9+
<head>
10+
<base/>
11+
<link/>
12+
</head>
13+
<body>
14+
<area alt=""/>
15+
<br/>
16+
<table>
17+
<colgroup>
18+
<col/>
19+
</colgroup>
20+
</table>
21+
<embed/>
22+
<hr/>
23+
<img src="" alt=""/>
24+
<input type="text" id="test_input"/>
25+
<keygen/>
26+
<link/>
27+
<meta/>
28+
<param name="" value=""/>
29+
<video>
30+
<source/>
31+
<track src=""/>
32+
</video>
33+
<wbr/>
34+
35+
<label for="test_input"/>
36+
<style type="text/css"/>
37+
<div/>
38+
<span/>
39+
<text/>
40+
<render/>
41+
<each/>
42+
<translate/>
43+
<scope/>
44+
</body>
45+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento2\Tests\Html;
7+
8+
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
9+
10+
class HtmlSelfClosingTagsUnitTest extends AbstractSniffUnitTest
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
public function getErrorList()
16+
{
17+
return [1 => 9];
18+
}
19+
20+
/**
21+
* @inheritdoc
22+
*/
23+
public function getWarningList()
24+
{
25+
return [];
26+
}
27+
}

0 commit comments

Comments
 (0)