Merge pull request #36 from jeffreyguo/pulls/find-email-by-title

add new step definition to identify multiple emails by from to and title
This commit is contained in:
Ingo Schommer 2014-06-04 13:26:48 +12:00
commit 1af1620fb4
1 changed files with 19 additions and 1 deletions

View File

@ -142,10 +142,28 @@ class EmailContext extends BehatContext
assertNotNull($linkEl);
$link = $linkEl->attr('href');
assertNotNull($link);
return new Step\When(sprintf('I go to "%s"', $link));
}
/**
* @When /^I click on the "([^"]*)" link in the email (to|from) "([^"]*)" titled "([^"]*)"$/
*/
public function iGoToInTheEmailToTitled($linkSelector, $direction, $email, $title)
{
$to = ($direction == 'to') ? $email : null;
$from = ($direction == 'from') ? $email : null;
$match = $this->mailer->findEmail($to, $from, $title);
assertNotNull($match);
$crawler = new Crawler($match->Content);
$linkEl = $crawler->selectLink($linkSelector);
assertNotNull($linkEl);
$link = $linkEl->attr('href');
assertNotNull($link);
return new Step\When(sprintf('I go to "%s"', $link));
}
/**
* Assumes an email has been identified by a previous step,
* e.g. through 'Given there should be an email to "test@test.com"'.