[Mailer] Catch missing scheme in DSN.
This commit is contained in:
parent
cf728f5da2
commit
3eba36c088
@ -69,11 +69,18 @@ class TransportTest extends TestCase
|
|||||||
Transport::fromDsn('some://');
|
Transport::fromDsn('some://');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNoScheme()
|
||||||
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
$this->expectExceptionMessage('The "//sendmail" mailer DSN must contain a transport scheme.');
|
||||||
|
Transport::fromDsn('//sendmail');
|
||||||
|
}
|
||||||
|
|
||||||
public function testFromInvalidDsnNoHost()
|
public function testFromInvalidDsnNoHost()
|
||||||
{
|
{
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
$this->expectExceptionMessage('The "?!" mailer DSN must contain a mailer name.');
|
$this->expectExceptionMessage('The "file:///some/path" mailer DSN must contain a mailer name.');
|
||||||
Transport::fromDsn('?!');
|
Transport::fromDsn('file:///some/path');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFromInvalidTransportName()
|
public function testFromInvalidTransportName()
|
||||||
|
@ -64,6 +64,10 @@ class Transport
|
|||||||
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN is invalid.', $dsn));
|
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN is invalid.', $dsn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($parsedDsn['scheme'])) {
|
||||||
|
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN must contain a transport scheme.', $dsn));
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($parsedDsn['host'])) {
|
if (!isset($parsedDsn['host'])) {
|
||||||
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN must contain a mailer name.', $dsn));
|
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN must contain a mailer name.', $dsn));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user