$domDoc = new DOMDocument();
$domDoc->loadHTML($docSrc);
$xpath = new DOMXPath($domDoc);
$nodeList = $xpath->query("//a[@class='active' and @href='/advanced-2-0.html']");
$this->assertTrue($nodeList->length == 1);
This code works great if $docSrc
is something like this:
$docSrc = '<div><a class="active" href = "/advanced-2-0.html']"></div>';
but when I assign HTML to $docSrc
like this:
$this->dispatch($_SERVER['REQUEST_URI']);
$html = $this->getResponse()->getBody();
it doesn't work. I print $html
and everything is ok inside; I can't explain it because in both cases it's a string.
I get the error:
AccountControllerTest::testIfAllow DOMDocument::loadHTML(): Namespace prefix fb is not defined in Entity, line: 54
I also tried:
$domDoc->loadHTML("$this->getResponse()->getBody()");
Errors don't appear, but the result is empty.