-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Labels
Description
I'm writing a codeception test helper that parses an email using eXorus\PhpMimeMailParser\Parser, then uses DomCrawler to find a uri inside the email.
Here's the code:
<?php
namespace Codeception\Module;
use eXorus\PhpMimeMailParser\Parser;
use Symfony\Component\DomCrawler\Crawler;
class MailHelper extends \Codeception\Lib\InnerBrowser
{
public static $includeInheritedActions = false;
protected $parser;
public function _before(\Codeception\TestCase $test)
{
$this->parser = new Parser();
parent::_before($test);
}
public function openEmail($email)
{
$this->parser->setText($email);
$this->crawler = new Crawler($this->parser->getMessageBody('html'), 'http://localhost');
}
public function getEmailLink($link)
{
return $this->crawler->selectLink($link)->link()->getUri();
}
}
If I don't call the Crawler constructor with 'http://localhost'
, it throws an exception ("Current URI must be an absolute URL") inside Link
's constructor
Why does Link::getUri
need the current uri if the link is absolute? It should only throw an exception if the current uri is not set and the link is relative, so I can detect if I have a bug and send relative (and protocol-relative) urls in emails.