Skip to content

Commit

Permalink
[9.x] Add hasSubject method to Mailables (#41575)
Browse files Browse the repository at this point in the history
* Add hasSubject method

* Add tests for hasSubject

* Update Mailable.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
MaxGiting and taylorotwell committed Mar 19, 2022
1 parent 066eb53 commit bffc647
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Illuminate/Mail/Mailable.php
Expand Up @@ -777,6 +777,17 @@ public function subject($subject)
return $this;
}

/**
* Determine if the mailable has the given subject.
*
* @param string $subject
* @return bool
*/
public function hasSubject($subject)
{
return $this->subject === $subject;
}

/**
* Set the Markdown template for the message.
*
Expand Down
7 changes: 7 additions & 0 deletions tests/Mail/MailMailableTest.php
Expand Up @@ -304,6 +304,13 @@ public function testMailableSetsFromCorrectly()
}
}

public function testMailableSetsSubjectCorrectly()
{
$mailable = new WelcomeMailableStub;
$mailable->subject('foo');
$this->assertTrue($mailable->hasSubject('foo'));
}

public function testItIgnoresDuplicatedRawAttachments()
{
$mailable = new WelcomeMailableStub;
Expand Down

0 comments on commit bffc647

Please sign in to comment.