TestCase::setAddress(): add support for `ReplyTo`

This allows for using the `setAddress()` method in a more consistent manner (where appropriate).

Includes introducing the use of the `setAddress()` function in a few select places.

Note: I do wonder whether this method should ever be used outside of `set_up()` and `tear_down()`, but that is for further discussion and outside the scope of this commit.
This commit is contained in:
jrfnl 2021-06-29 13:18:00 +02:00
parent 1c32844af2
commit af68fb202a
2 changed files with 4 additions and 2 deletions

View File

@ -81,7 +81,7 @@ final class MailTransportTest extends TestCase
$this->setAddress('testmailsend@example.com', 'totest');
$this->setAddress('cctestmailsend@example.com', 'cctest', $sType = 'cc');
$this->setAddress('bcctestmailsend@example.com', 'bcctest', $sType = 'bcc');
$this->Mail->addReplyTo('replytotestmailsend@example.com', 'replytotest');
$this->setAddress('replytotestmailsend@example.com', 'replytotest', $sType = 'ReplyTo');
self::assertContains('testmailsend@example.com', $this->Mail->getToAddresses()[0], 'To address not found');
self::assertContains('cctestmailsend@example.com', $this->Mail->getCcAddresses()[0], 'CC address not found');

View File

@ -121,7 +121,7 @@ abstract class TestCase extends PolyfillTestCase
if (array_key_exists('mail_userpass', $_REQUEST)) {
$this->Mail->Password = $_REQUEST['mail_userpass'];
}
$this->Mail->addReplyTo('no_reply@phpmailer.example.com', 'Reply Guy');
$this->setAddress('no_reply@phpmailer.example.com', 'Reply Guy', 'ReplyTo');
$this->Mail->Sender = 'unit_test@phpmailer.example.com';
if ($this->Mail->Host != '') {
$this->Mail->isSMTP();
@ -297,6 +297,8 @@ abstract class TestCase extends PolyfillTestCase
return $this->Mail->addCC($sAddress, $sName);
case 'bcc':
return $this->Mail->addBCC($sAddress, $sName);
case 'ReplyTo':
return $this->Mail->addReplyTo($sAddress, $sName);
}
return false;