Skip to content

Commit

Permalink
FIX Emails are arrays
Browse files Browse the repository at this point in the history
Work missed during #232
  • Loading branch information
GuySartorelli committed Jan 27, 2023
1 parent dfcafd6 commit 73126ea
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/Context/EmailContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ public function thereTheEmailContains($negate, $content)

$email = $this->lastMatchedEmail;
$emailContent = null;
if ($email->Content) {
$emailContent = $email->Content;
if ($email['Content']) {
$emailContent = $email['Content'];
} else {
$emailContent = $email->PlainContent;
$emailContent = $email['PlainContent'];
}

if (trim($negate ?? '')) {
Expand All @@ -154,8 +154,7 @@ public function thereTheEmailContainsPlainText($content)
}

$email = $this->lastMatchedEmail;
$emailContent = ($email->Content) ? ($email->Content) : ($email->PlainContent);
$emailPlainText = strip_tags($emailContent ?? '');
$emailPlainText = $email['PlainContent'] ? $email['PlainContent'] : strip_tags($email['Content']);
$emailPlainText = preg_replace("/\h+/", " ", $emailPlainText ?? '');

Assert::assertStringContainsString($content, $emailPlainText);
Expand Down Expand Up @@ -219,7 +218,7 @@ public function iGoToInTheEmail($linkSelector)
}

$match = $this->lastMatchedEmail;
$crawler = new Crawler($match->Content);
$crawler = new Crawler($match['Content']);
$linkEl = $crawler->selectLink($linkSelector);
Assert::assertNotNull($linkEl);
$link = $linkEl->attr('href');
Expand Down Expand Up @@ -254,10 +253,10 @@ public function theEmailContainFollowingData($negate, TableNode $table)

$email = $this->lastMatchedEmail;
$emailContent = null;
if ($email->Content) {
$emailContent = $email->Content;
if ($email['Content']) {
$emailContent = $email['Content'];
} else {
$emailContent = $email->PlainContent;
$emailContent = $email['PlainContent'];
}
// Convert html content to plain text
$emailContent = strip_tags($emailContent ?? '');
Expand Down Expand Up @@ -309,9 +308,9 @@ public function theEmailSentFrom($negate, $from)

$match = $this->lastMatchedEmail;
if (trim($negate ?? '')) {
Assert::assertStringNotContainsString($from, $match->From);
Assert::assertStringNotContainsString($from, $match['From']);
} else {
Assert::assertStringContainsString($from, $match->From);
Assert::assertStringContainsString($from, $match['From']);
}
}

Expand All @@ -328,9 +327,9 @@ public function theEmailSentTo($negate, $to)

$match = $this->lastMatchedEmail;
if (trim($negate ?? '')) {
Assert::assertStringNotContainsString($to, $match->To);
Assert::assertStringNotContainsString($to, $match['To']);
} else {
Assert::assertStringContainsString($to, $match->To);
Assert::assertStringContainsString($to, $match['To']);
}
}

Expand All @@ -348,7 +347,7 @@ public function iClickOnHttpLinkInEmail($httpText)
}

$email = $this->lastMatchedEmail;
$html = $email->Content;
$html = $email['Content'];
$dom = new \DOMDocument();
$dom->loadHTML($html);

Expand Down

0 comments on commit 73126ea

Please sign in to comment.