Skip to content

Add test coverage for HtmlBindingSniff #217

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
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/Html/HtmlBindingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function process(File $phpcsFile, $stackPtr)
. ' - "' . $htmlBinding . '" doesn\'t,' . PHP_EOL
. 'consider using text binding if the value is supposed to be text',
null,
'UIComponentTemplate.KnockoutBinding.HtmlSuffix'
'KnockoutBindingHtmlSuffix'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: in past, the error wasn't added at all.

);
}
}
Expand Down
30 changes: 30 additions & 0 deletions Magento2/Tests/Html/HtmlBindingSniffUnitTest.1.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<div data-bind="attr: test.value"></div>
<p>Test</p>
<span data-bind="html: testError()"></span>
<div data-bind="
attr : tst,
html: test.getSomething().value.error()
"></div>
<p data-bind="html: '<b>Some html</b>', attr: test"></p>
<div data-bind="html: valueUnsanitizedHtml"></div>
<div data-bind="attr: testhtml, html: valueUnsanitizedHtml()"></div>
<p data-bind="other_html: bind, html: bind_stuff(1, 2)"></p>

<div style="tst()"></div>
<span html="testError()"></span>
<div html="
test.getSomething().value.error(1)
"></div>
<p html="'<b>Some html</b>'"></p>
<div html="valueUnsanitizedHtml"></div>
<div html="
valueUnsanitizedHtml('test')
"></div>
<p html="bind_stuff()"></p>
27 changes: 27 additions & 0 deletions Magento2/Tests/Html/HtmlBindingUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright © Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento2\Tests\Html;

use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;

class HtmlBindingUnitTest extends AbstractSniffUnitTest
{
/**
* @inheritdoc
*/
public function getErrorList()
{
return [1 => 6];
}

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