From 6ca6b0c11df7cf5f4a03461b54158bf406149e37 Mon Sep 17 00:00:00 2001 From: James <61766491+lioneaglesolutions@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:51:31 +1000 Subject: [PATCH] [11.x] Add additional context to Mailable assertion messages (#49631) * add recipient type to message * fix tests --- src/Illuminate/Mail/Mailable.php | 6 +++--- tests/Mail/MailMailableTest.php | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Illuminate/Mail/Mailable.php b/src/Illuminate/Mail/Mailable.php index 7bdf38ad8541..4016ee5a210e 100644 --- a/src/Illuminate/Mail/Mailable.php +++ b/src/Illuminate/Mail/Mailable.php @@ -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; @@ -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; @@ -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; diff --git a/tests/Mail/MailMailableTest.php b/tests/Mail/MailMailableTest.php index 8e17cce973a6..9c21f8b06dc8 100644 --- a/tests/Mail/MailMailableTest.php +++ b/tests/Mail/MailMailableTest.php @@ -61,7 +61,7 @@ public function render() $mailable->assertHasTo('taylor@laravel.com', 'Taylor Otwell'); $this->fail(); } catch (AssertionFailedError $e) { - $this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email recipients.\nFailed asserting that false is true.", $e->getMessage()); + $this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email 'to' recipients.\nFailed asserting that false is true.", $e->getMessage()); } $mailable = new WelcomeMailableStub; @@ -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()); } } } @@ -146,7 +146,7 @@ public function render() $mailable->assertHasCc('taylor@laravel.com', 'Taylor Otwell'); $this->fail(); } catch (AssertionFailedError $e) { - $this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email recipients.\nFailed asserting that false is true.", $e->getMessage()); + $this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email 'cc' recipients.\nFailed asserting that false is true.", $e->getMessage()); } $mailable = new WelcomeMailableStub; @@ -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()); } } } @@ -243,7 +243,7 @@ public function render() $mailable->assertHasBcc('taylor@laravel.com', 'Taylor Otwell'); $this->fail(); } catch (AssertionFailedError $e) { - $this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email recipients.\nFailed asserting that false is true.", $e->getMessage()); + $this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email 'bcc' recipients.\nFailed asserting that false is true.", $e->getMessage()); } $mailable = new WelcomeMailableStub; @@ -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()); } } }