Skip to content
Snippets Groups Projects
Commit 4e63d081 authored by Bryce Lowe's avatar Bryce Lowe
Browse files

Added test cases for invalid transport method and invalid smtp configuration

parent 0950aac4
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ namespace SimpleSAML\Test\Utils; ...@@ -5,6 +5,7 @@ namespace SimpleSAML\Test\Utils;
use SimpleSAML\Test\Utils\TestCase; use SimpleSAML\Test\Utils\TestCase;
use SimpleSAML\Configuration; use SimpleSAML\Configuration;
use SimpleSAML\Utils\Config;
use SimpleSAML\Utils\EMail; use SimpleSAML\Utils\EMail;
/** /**
...@@ -71,4 +72,34 @@ class EMailTestCase extends ClearStateTestCase ...@@ -71,4 +72,34 @@ class EMailTestCase extends ClearStateTestCase
{ {
return [['mailtxt.twig'], ['mailhtml.twig']]; return [['mailtxt.twig'], ['mailhtml.twig']];
} }
public function testInvalidTransportConfiguration()
{
// preserve the original configuration
$originalTestConfiguration = Configuration::getInstance()->toArray();
// load the configuration with an invalid mail.transport.method
Configuration::loadFromArray(array_merge($originalTestConfiguration, [
'mail.transport.method' => 'foobar'
]), '[ARRAY]', 'simplesaml');
$this->expectException(\InvalidArgumentException::class);
new Email('Test', 'phpunit@simplesamlphp.org', 'phpunit@simplesamlphp.org');
// reset the configuration
Configuration::loadFromArray($originalTestConfiguration, '[ARRAY]', 'simplesaml');
}
public function testInvalidSMTPConfiguration()
{
// setup a new email
$email = new Email('Test', 'phpunit@simplesamlphp.org', 'phpunit@simplesamlphp.org');
// set the transport option to smtp but don't set any transport options (invalid state)
// NOTE: this is the same method that the constructor calls, so this should be logically equivalent
// to setting it via the configuration file.
$this->expectException(\InvalidArgumentException::class);
$email->setTransportMethod('smtp');
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment