php - Symfony2 DOMCrawler selectLink returns null uri
I have a problem with writing functional tests and DOMCrawler. My issue is to crawl through mail content with link. From docs i saw that the crawler can be created with html content as parameter. So this is my chunk of code:
$mailCrawler = new Crawler($message->getBody());
$linkCrawler = $mailCrawler->selectLink('Link name');
$client->click($linkCrawler->link());
On third line I have an exception because $linkCrawler has empty $uri field. Exception message:
InvalidArgumentException: Current URI must be an absolute URL ("").
Can anyone tell me why crawler cant get that link?
I can only tell that the $message var getBody method returns correct content.
Regards
Answer
Solution:
You need to specify root crawler url. Example: