JanZerebecki added a comment. I agree I'm against any regexp that tries to parse HTML or XML. We should never do that. I dislike the assertTag matchers syntax and prefer CSS. Because more people know CSS. (Even more than XPath which I would otherwise prefer). Also it is more expressive than assertTag matchers syntax. There was a reason why assertTag was removed from PHPUnit, see https://github.com/sebastianbergmann/phpunit/issues/1292 for some of the context. We should not replicate those errors. Or if we absolutely must replicate assertTag contribute to https://github.com/phpunit/phpunit-dom-assertions . For text content matching regexp is ok.
So e.g. http://symfony.com/doc/current/components/dom_crawler.html used with http://symfony.com/doc/current/components/css_selector.html for directly asserting something seems like a good idea. Or for more complex things one could use one selector to find and another that every result matches something. However ensuring that a string is well formed HTML or XML with DomCrawler in addition requires enabling the libxml error reporting. Or use PHPunits assertEqualXMLStructure() to match the selection of nodes, assertRegExp() for the text in text nodes. There is also assertXmlStringEqualsXmlString() and friens when you want to compare two documents in string form as is. There is probably some additional code needed to make DomCrawler into usable assertions, but that should result in something that is more long term proof. See https://github.com/phpunit/phpunit-dom-assertions/blob/master/src/DOMTestCase.php for an example usage of DomCrawler (but it misses checking for libxml errors). If we prefer something that better handles namespaces than DomCrawler, we probably need to look at https://github.com/FluentDOM/FluentDOM . TASK DETAIL https://phabricator.wikimedia.org/T69122 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: JanZerebecki Cc: JanZerebecki, Ricordisamoa, gerritbot, Aklapper, Wikidata-bugs, Bene, Tobi_WMDE_SW, JeroenDeDauw, adrianheine, Lydia_Pintscher, daniel, aude _______________________________________________ Wikidata-bugs mailing list Wikidata-bugs@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs