Skip to content

Commit

Permalink
[11.x] Add additional context to Mailable assertion messages (laravel…
Browse files Browse the repository at this point in the history
…#49631)

* add recipient type to message

* fix tests
  • Loading branch information
lioneaglesolutions authored and frankiejarrett committed Jan 10, 2024
1 parent b100b8a commit 6ca6b0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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

0 comments on commit 6ca6b0c

Please sign in to comment.