diff --git a/lib/Cake/Network/Email/SmtpTransport.php b/lib/Cake/Network/Email/SmtpTransport.php index a003e467c79..22ba6568ba5 100644 --- a/lib/Cake/Network/Email/SmtpTransport.php +++ b/lib/Cake/Network/Email/SmtpTransport.php @@ -71,9 +71,12 @@ public function send(CakeEmail $email) { * Set the configuration * * @param array $config - * @return void + * @return array Returns configs */ - public function config($config = array()) { + public function config($config = null) { + if ($config === null) { + return $this->_config; + } $default = array( 'host' => 'localhost', 'port' => 25, @@ -83,7 +86,8 @@ public function config($config = array()) { 'client' => null, 'tls' => false ); - $this->_config = $config + $default; + $this->_config = empty($config) ? $this->_config + $default : $config + $default; + return $this->_config; } /** diff --git a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php index 625fcdcbea6..e97bb0ce231 100644 --- a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php @@ -327,4 +327,21 @@ public function testQuit() { $this->SmtpTransport->disconnect(); } +/** + * testEmptyConfigArray method + * + * @return void + */ + public function testEmptyConfigArray() { + $expected = $this->SmtpTransport->config(array( + 'client' => 'myhost.com', + 'port' => 666 + )); + + $this->assertEquals(666, $expected['port']); + + $result = $this->SmtpTransport->config(array()); + $this->assertEquals($expected, $result); + } + }