Skip to content

Commit bffc647

Browse files
[9.x] Add hasSubject method to Mailables (#41575)
* Add hasSubject method * Add tests for hasSubject * Update Mailable.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 066eb53 commit bffc647

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Illuminate/Mail/Mailable.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,17 @@ public function subject($subject)
777777
return $this;
778778
}
779779

780+
/**
781+
* Determine if the mailable has the given subject.
782+
*
783+
* @param string $subject
784+
* @return bool
785+
*/
786+
public function hasSubject($subject)
787+
{
788+
return $this->subject === $subject;
789+
}
790+
780791
/**
781792
* Set the Markdown template for the message.
782793
*

tests/Mail/MailMailableTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,13 @@ public function testMailableSetsFromCorrectly()
304304
}
305305
}
306306

307+
public function testMailableSetsSubjectCorrectly()
308+
{
309+
$mailable = new WelcomeMailableStub;
310+
$mailable->subject('foo');
311+
$this->assertTrue($mailable->hasSubject('foo'));
312+
}
313+
307314
public function testItIgnoresDuplicatedRawAttachments()
308315
{
309316
$mailable = new WelcomeMailableStub;

0 commit comments

Comments
 (0)