mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Ensure passing empty array to SmtpTransport::config() does not reset existing config.
Synced args and return value with AbstractTransport::config(). Fixes #3840
This commit is contained in:
parent
1357b00843
commit
eccdf3bf60
2 changed files with 24 additions and 3 deletions
|
@ -71,9 +71,12 @@ class SmtpTransport extends AbstractTransport {
|
|||
* 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 @@ class SmtpTransport extends AbstractTransport {
|
|||
'client' => null,
|
||||
'tls' => false
|
||||
);
|
||||
$this->_config = $config + $default;
|
||||
$this->_config = empty($config) ? $this->_config + $default : $config + $default;
|
||||
return $this->_config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -327,4 +327,21 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue