Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Add additional context to Mailable assertion messages #49631

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Illuminate/Mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ public function assertTo($address, $name = null)

PHPUnit::assertTrue(
$this->hasTo($address, $name),
"Did not see expected recipient [{$recipient}] in email recipients."
"Did not see expected recipient [{$recipient}] in email 'to' recipients."
);

return $this;
Expand Down Expand Up @@ -1264,7 +1264,7 @@ public function assertHasCc($address, $name = null)

PHPUnit::assertTrue(
$this->hasCc($address, $name),
"Did not see expected recipient [{$recipient}] in email recipients."
"Did not see expected recipient [{$recipient}] in email 'cc' recipients."
);

return $this;
Expand All @@ -1285,7 +1285,7 @@ public function assertHasBcc($address, $name = null)

PHPUnit::assertTrue(
$this->hasBcc($address, $name),
"Did not see expected recipient [{$recipient}] in email recipients."
"Did not see expected recipient [{$recipient}] in email 'bcc' recipients."
);

return $this;
Expand Down
12 changes: 6 additions & 6 deletions tests/Mail/MailMailableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function render()
$mailable->assertHasTo('[email protected]', 'Taylor Otwell');
$this->fail();
} catch (AssertionFailedError $e) {
$this->assertSame("Did not see expected recipient [[email protected] (Taylor Otwell)] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
$this->assertSame("Did not see expected recipient [[email protected] (Taylor Otwell)] in email 'to' recipients.\nFailed asserting that false is true.", $e->getMessage());
}

$mailable = new WelcomeMailableStub;
Expand Down Expand Up @@ -107,7 +107,7 @@ public function render()
if (! is_string($address)) {
$address = json_encode($address);
}
$this->assertSame("Did not see expected recipient [{$address}] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
$this->assertSame("Did not see expected recipient [{$address}] in email 'to' recipients.\nFailed asserting that false is true.", $e->getMessage());
}
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ public function render()
$mailable->assertHasCc('[email protected]', 'Taylor Otwell');
$this->fail();
} catch (AssertionFailedError $e) {
$this->assertSame("Did not see expected recipient [[email protected] (Taylor Otwell)] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
$this->assertSame("Did not see expected recipient [[email protected] (Taylor Otwell)] in email 'cc' recipients.\nFailed asserting that false is true.", $e->getMessage());
}

$mailable = new WelcomeMailableStub;
Expand Down Expand Up @@ -204,7 +204,7 @@ public function render()
if (! is_string($address)) {
$address = json_encode($address);
}
$this->assertSame("Did not see expected recipient [{$address}] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
$this->assertSame("Did not see expected recipient [{$address}] in email 'cc' recipients.\nFailed asserting that false is true.", $e->getMessage());
}
}
}
Expand Down Expand Up @@ -243,7 +243,7 @@ public function render()
$mailable->assertHasBcc('[email protected]', 'Taylor Otwell');
$this->fail();
} catch (AssertionFailedError $e) {
$this->assertSame("Did not see expected recipient [[email protected] (Taylor Otwell)] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
$this->assertSame("Did not see expected recipient [[email protected] (Taylor Otwell)] in email 'bcc' recipients.\nFailed asserting that false is true.", $e->getMessage());
}

$mailable = new WelcomeMailableStub;
Expand Down Expand Up @@ -301,7 +301,7 @@ public function render()
if (! is_string($address)) {
$address = json_encode($address);
}
$this->assertSame("Did not see expected recipient [{$address}] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
$this->assertSame("Did not see expected recipient [{$address}] in email 'bcc' recipients.\nFailed asserting that false is true.", $e->getMessage());
}
}
}
Expand Down