nette / tester

Tester: enjoyable unit testing in PHP with code coverage reporter. 🍏🍏🍎🍏
https://tester.nette.org
Other
453 stars 71 forks source link

DOMDocument::loadHTML() - cannot parse HTML5 elements #130

Closed radimsuckr closed 10 years ago

radimsuckr commented 10 years ago

PHP 5.5.12 (openSUSE 13.1)

When I have following HTML code:

<nav class="navbar navbar-default navbar-static-top" role="navigation">

And this line in test:

$dom = Tester\DomQuery::fromHtml((string) $response->getSource());

Test fails on <nav> element with error: E_WARNING: DOMDocument::loadHTML(): Tag nav invalid in Entity

I found some answer on Stackoverflow and it looks like it's a bug in DOMDocument, but I think that Nette\Tester should treat this.

JanTvrdik commented 10 years ago

There is no easy way to workaround for this. As explain on forum

http://forum.nette.org/en/1184-tester-domquery-fromhtml-error http://forum.nette.org/en/1396-tester-domquery-invalid-tag-in-entity

It would require setting a custom error handler and parsing the warning or ignoring all warnings.

radimsuckr commented 10 years ago

Fixed by https://github.com/nette/tester/commit/e60cf2d0718f6daf88426bb012e03a7c939cd2ac. Thanks to @dg.