Skip to content

Commit 784bf76

Browse files
[11.x] Add additional context to Mailable assertion messages (#49631)
* add recipient type to message * fix tests
1 parent e63cea8 commit 784bf76

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Illuminate/Mail/Mailable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ public function assertTo($address, $name = null)
12311231

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

12371237
return $this;
@@ -1264,7 +1264,7 @@ public function assertHasCc($address, $name = null)
12641264

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

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

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

12911291
return $this;

tests/Mail/MailMailableTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function render()
6161
$mailable->assertHasTo('taylor@laravel.com', 'Taylor Otwell');
6262
$this->fail();
6363
} catch (AssertionFailedError $e) {
64-
$this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
64+
$this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email 'to' recipients.\nFailed asserting that false is true.", $e->getMessage());
6565
}
6666

6767
$mailable = new WelcomeMailableStub;
@@ -107,7 +107,7 @@ public function render()
107107
if (! is_string($address)) {
108108
$address = json_encode($address);
109109
}
110-
$this->assertSame("Did not see expected recipient [{$address}] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
110+
$this->assertSame("Did not see expected recipient [{$address}] in email 'to' recipients.\nFailed asserting that false is true.", $e->getMessage());
111111
}
112112
}
113113
}
@@ -146,7 +146,7 @@ public function render()
146146
$mailable->assertHasCc('taylor@laravel.com', 'Taylor Otwell');
147147
$this->fail();
148148
} catch (AssertionFailedError $e) {
149-
$this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
149+
$this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email 'cc' recipients.\nFailed asserting that false is true.", $e->getMessage());
150150
}
151151

152152
$mailable = new WelcomeMailableStub;
@@ -204,7 +204,7 @@ public function render()
204204
if (! is_string($address)) {
205205
$address = json_encode($address);
206206
}
207-
$this->assertSame("Did not see expected recipient [{$address}] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
207+
$this->assertSame("Did not see expected recipient [{$address}] in email 'cc' recipients.\nFailed asserting that false is true.", $e->getMessage());
208208
}
209209
}
210210
}
@@ -243,7 +243,7 @@ public function render()
243243
$mailable->assertHasBcc('taylor@laravel.com', 'Taylor Otwell');
244244
$this->fail();
245245
} catch (AssertionFailedError $e) {
246-
$this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email recipients.\nFailed asserting that false is true.", $e->getMessage());
246+
$this->assertSame("Did not see expected recipient [taylor@laravel.com (Taylor Otwell)] in email 'bcc' recipients.\nFailed asserting that false is true.", $e->getMessage());
247247
}
248248

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

0 commit comments

Comments
 (0)