/** * {@inheritdoc} */ public function matches(Email $email) { if ($this->url_pattern) { return (bool) $email->getLinksMatching($this->url_pattern); } else { return (bool) $email->getLinks(); } }
/** * @param \Ingenerator\Mailhook\Email $email */ function it_matches_email_with_matching_link_when_pattern_provided($email) { $this->beConstructedWith('/reset/'); $email->getLinksMatching('/reset/')->willReturn(array('href' => 'http://foo.bar/reset')); $this->subject->matches($email)->shouldBe(TRUE); }
function it_filters_links_by_regular_expression() { $this->subject->beConstructedWith(array('links' => array('https://www.ingenerator.com/test/matching-url', 'https://www.ingenerator.com/test/notmatch-url'))); $this->subject->getLinksMatching('_matching-url$_')->shouldBe(array('https://www.ingenerator.com/test/matching-url')); }