Merge branch 'master' into 2.4

This commit is contained in:
mark_story 2013-08-16 14:47:01 -04:00
commit 3244b9e3d7
16 changed files with 115 additions and 22 deletions

View file

@ -95,6 +95,20 @@ class EmailConfig {
'helpers' => array('Html', 'Form'),
);
/**
* test config 2
*
* @var string
*/
public $test2 = array(
'from' => array('some@example.com' => 'My website'),
'to' => array('test@example.com' => 'Testname'),
'subject' => 'Test mail subject',
'transport' => 'Smtp',
'host' => 'cakephp.org',
'timeout' => 60
);
}
/*
@ -789,12 +803,13 @@ class CakeEmailTest extends CakeTestCase {
$this->assertSame($this->CakeEmail->config(), $config);
$this->CakeEmail->config(array());
$this->assertSame($transportClass->config(), array());
$this->assertSame($transportClass->config(), $config);
$config = array('test' => 'test@example.com');
$this->CakeEmail->config($config);
$expected = array('test' => 'test@example.com', 'test2' => true);
$this->assertSame($expected, $this->CakeEmail->config());
$this->assertSame($expected, $transportClass->config());
}
/**
@ -828,6 +843,35 @@ class CakeEmailTest extends CakeTestCase {
$this->assertEquals($configs->test['helpers'], $result);
}
/**
* Test updating config doesn't reset transport's config.
*
* @return void
*/
public function testConfigMerge() {
$this->CakeEmail->config('test2');
$expected = array(
'host' => 'cakephp.org',
'port' => 25,
'timeout' => 60,
'username' => null,
'password' => null,
'client' => null,
'tls' => false
);
$this->assertEquals($expected, $this->CakeEmail->transportClass()->config());
$this->CakeEmail->config(array('log' => true));
$result = $this->CakeEmail->transportClass()->config();
$expected += array('log' => true);
$this->assertEquals($expected, $this->CakeEmail->transportClass()->config());
$this->CakeEmail->config(array('timeout' => 45));
$result = $this->CakeEmail->transportClass()->config();
$this->assertEquals(45, $result['timeout']);
}
/**
* testSendWithContent method
*
@ -1177,6 +1221,26 @@ class CakeEmailTest extends CakeTestCase {
$this->assertContains('To: ', $result['headers']);
}
/**
* test sending and rendering with no layout
*
* @return void
*/
public function testSendRenderNoLayout() {
$this->CakeEmail->reset();
$this->CakeEmail->transport('debug');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->to(array('you@cakephp.org' => 'You'));
$this->CakeEmail->subject('My title');
$this->CakeEmail->config(array('empty'));
$this->CakeEmail->template('default', null);
$result = $this->CakeEmail->send('message body.');
$this->assertContains('message body.', $result['message']);
$this->assertNotContains('This email was sent using the CakePHP Framework', $result['message']);
}
/**
* testSendRender method for ISO-2022-JP
*