FIX Emails are arrays in TestMailer

This commit is contained in:
Guy Sartorelli 2022-10-27 13:45:09 +13:00
parent 8c06503294
commit 2601cd8e01
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A
2 changed files with 10 additions and 9 deletions

View File

@ -89,7 +89,7 @@ class EmailContext implements Context
$match = $this->mailer->findEmail($to, $from, $subject);
$allMails = $this->mailer->findEmails($to, $from);
$allTitles = $allMails ? '"' . implode('","', array_map(function ($email) {
return $email->Subject;
return $email['Subject'];
}, $allMails)) . '"' : null;
if (trim($negate ?? '')) {
Assert::assertNull($match);
@ -174,7 +174,7 @@ class EmailContext implements Context
$match = $this->mailer->findEmail($to, $from);
Assert::assertNotNull($match);
$crawler = new Crawler($match->Content);
$crawler = new Crawler($match['Content']);
$linkEl = $crawler->selectLink($linkSelector);
Assert::assertNotNull($linkEl);
$link = $linkEl->attr('href');
@ -197,7 +197,7 @@ class EmailContext implements Context
$match = $this->mailer->findEmail($to, $from, $title);
Assert::assertNotNull($match);
$crawler = new Crawler($match->Content);
$crawler = new Crawler($match['Content']);
$linkEl = $crawler->selectLink($linkSelector);
Assert::assertNotNull($linkEl);
$link = $linkEl->attr('href');
@ -283,7 +283,7 @@ class EmailContext implements Context
*/
public function thereIsAnEmailTitled($negate, $subject)
{
$match = $this->mailer->findEmail(null, null, $subject);
$match = $this->mailer->findEmail('', null, $subject);
if (trim($negate ?? '')) {
Assert::assertNull($match);
} else {

View File

@ -68,6 +68,7 @@ class TestMailer extends BaseTestMailer
//got the count of matches emails
$emailCount = count($matches ?? []);
//get the last(latest) one
return $matches ? $matches[$emailCount-1] : null;
}
@ -108,14 +109,14 @@ class TestMailer extends BaseTestMailer
}
}
if ($matched) {
$matches[] = $email;
$matches[] = json_decode(json_encode($email), true);
}
}
return $matches;
}
protected function saveEmail($data)
protected function saveEmail(array $data)
{
$state = $this->testSessionEnvironment->getState();
if (!isset($state->emails)) {