Permalink
Browse files

Ensure passing empty array to SmtpTransport::config() does not reset …

…existing config.

Synced args and return value with AbstractTransport::config().

Fixes #3840
  • Loading branch information...
ADmad committed May 22, 2013
1 parent 1357b00 commit eccdf3bf6037b65586d9f5e868a1c772fd4010df
Showing with 24 additions and 3 deletions.
  1. +7 −3 lib/Cake/Network/Email/SmtpTransport.php
  2. +17 −0 lib/Cake/Test/Case/Network/Email/SmtpTransportTest.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;
}
/**
@@ -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);
+ }
+
}

0 comments on commit eccdf3b

Please sign in to comment.