Commit b20e5768 by Paul Klimov

"yii\swiftmailer\Mailer::createSwiftObject()" simplified.

parent 704f9105
...@@ -192,7 +192,7 @@ class Mailer extends BaseMailer ...@@ -192,7 +192,7 @@ class Mailer extends BaseMailer
} }
} }
unset($config['constructArgs']); unset($config['constructArgs']);
array_unshift($args, ['class' => $className]); array_unshift($args, $className);
$object = call_user_func_array(['Yii', 'createObject'], $args); $object = call_user_func_array(['Yii', 'createObject'], $args);
} else { } else {
$object = new $className; $object = new $className;
......
...@@ -70,10 +70,11 @@ class MailerTest extends VendorTestCase ...@@ -70,10 +70,11 @@ class MailerTest extends VendorTestCase
{ {
$mailer = new Mailer(); $mailer = new Mailer();
$class = 'Swift_SmtpTransport';
$host = 'some.test.host'; $host = 'some.test.host';
$port = 999; $port = 999;
$transportConfig = [ $transportConfig = [
'class' => 'Swift_SmtpTransport', 'class' => $class,
'constructArgs' => [ 'constructArgs' => [
$host, $host,
$port, $port,
...@@ -82,6 +83,7 @@ class MailerTest extends VendorTestCase ...@@ -82,6 +83,7 @@ class MailerTest extends VendorTestCase
$mailer->setTransport($transportConfig); $mailer->setTransport($transportConfig);
$transport = $mailer->getTransport(); $transport = $mailer->getTransport();
$this->assertTrue(is_object($transport), 'Unable to setup transport via config!'); $this->assertTrue(is_object($transport), 'Unable to setup transport via config!');
$this->assertEquals($class, get_class($transport), 'Invalid transport class!');
$this->assertEquals($host, $transport->getHost(), 'Invalid transport host!'); $this->assertEquals($host, $transport->getHost(), 'Invalid transport host!');
$this->assertEquals($port, $transport->getPort(), 'Invalid transport host!'); $this->assertEquals($port, $transport->getPort(), 'Invalid transport host!');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment