mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
FIX Emails are arrays in TestMailer
This commit is contained in:
parent
8c06503294
commit
2601cd8e01
@ -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 {
|
||||
|
@ -65,9 +65,10 @@ class TestMailer extends BaseTestMailer
|
||||
?string $content = null
|
||||
): ?array {
|
||||
$matches = $this->findEmails($to, $from, $subject, $content);
|
||||
//got the count of matches emails
|
||||
$emailCount = count($matches ?? []);
|
||||
//get the last(latest) one
|
||||
//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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user