-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug [mailer] fix EsmtpTransport variable $code definition
the variable $code defined in the foreach loop, if there is no authenticators, then the $code will not be defined and therefore the following TransportException gives a PHP error. the use-case defined as a unit test in EsmtpTransportTest class.
- Loading branch information
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,28 @@ public function testSetAuthenticators() | |
$stream->getCommands() | ||
); | ||
} | ||
|
||
public function testConstructorWithEmptyAuthenticator() | ||
{ | ||
$stream = new DummyStream(); | ||
$transport = new EsmtpTransport(stream: $stream); | ||
$transport->setUsername('testuser'); | ||
$transport->setPassword('p4ssw0rd'); | ||
$transport->setAuthenticators([]); // if no authenticators defined, then there needs to be a TransportException | ||
|
||
$message = new Email(); | ||
$message->from('[email protected]'); | ||
$message->addTo('[email protected]'); | ||
$message->text('.'); | ||
|
||
try { | ||
$transport->send($message); | ||
$this->fail('Symfony\Component\Mailer\Exception\TransportException to be thrown'); | ||
} catch (TransportException $e) { | ||
$this->assertStringStartsWith('Failed to find an authenticator supported by the SMTP server, which currently supports: "plain", "login", "cram-md5", "xoauth2".', $e->getMessage()); | ||
$this->assertEquals(504, $e->getCode()); | ||
} | ||
} | ||
} | ||
|
||
class CustomEsmtpTransport extends EsmtpTransport | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters