-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Description
Symfony version(s) affected
6.1, sort of
Description
The WebTestCaseTest::assertCheckboxChecked/assertCheckboxNotChecked assertions do not work with html5 content.
They are only tested with html 4 content.
If the html tag in these tests with <!DOCTYPE html>, the tests fail.
This is because, in html5, checked is a boolean attribute,
i.e this is valid:
<input type="checkbox" name="rememberMe" checked>
while this is not:
<input type="checkbox" name="rememberMe" checked="checked">
so the new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'checked', 'checked') check fails.
masterminds/html5 will parse <input type="checkbox" name="rememberMe" checked="checked"> as <input type="checkbox" name="rememberMe" checked>.
How to reproduce
They are only tested with html 4 content
Replace the html tag in these tests with <!DOCTYPE html>.
Possible Solution
not sure, maybe modify the assertion so it works with html4 and 5 parsers
LogicalOr(new CrawlerSelectorAttributeValueSame(...), new CrawlerSelectorAttributeExists(...))where CrawlerSelectorAttributeExists is a new Constraint.
Additional Context
We discoverd this issue while upgrading from symfony 5.4 to 6.1, because masterminds/html5 became a mandatory dependency in 6.1: #44170, so previously on 5.4, our html in functional tests was not parsed as html5.
it should be noted that html5 is used in a default symfony project:
https://github.com/symfony/recipes/blob/f54b694258dfcb356f6c59e2ce1a4c49f3cceae9/symfony/twig-bundle/5.4/templates/base.html.twig#L1