mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Add a few regression tests for CakeEmail.
This commit is contained in:
parent
bbef4aa36d
commit
34eedcc017
1 changed files with 62 additions and 0 deletions
|
@ -745,6 +745,68 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->CakeEmail->send("Forgot to set To");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test send() with no template.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSendNoTemplateWithAttachments() {
|
||||
$this->CakeEmail->transport('debug');
|
||||
$this->CakeEmail->from('cake@cakephp.org');
|
||||
$this->CakeEmail->to('cake@cakephp.org');
|
||||
$this->CakeEmail->subject('My title');
|
||||
$this->CakeEmail->emailFormat('text');
|
||||
$this->CakeEmail->attachments(array(CAKE . 'basics.php'));
|
||||
$result = $this->CakeEmail->send('Hello');
|
||||
|
||||
$boundary = $this->CakeEmail->getBoundary();
|
||||
$this->assertContains('Content-Type: multipart/mixed; boundary="' . $boundary . '"', $result['headers']);
|
||||
$expected = "--$boundary\r\n" .
|
||||
"Content-Type: text/plain; charset=UTF-8\r\n" .
|
||||
"Content-Transfer-Encoding: 8bit\r\n" .
|
||||
"\r\n" .
|
||||
"Hello" .
|
||||
"\r\n" .
|
||||
"\r\n" .
|
||||
"\r\n" .
|
||||
"--$boundary\r\n" .
|
||||
"Content-Type: application/octet-stream\r\n" .
|
||||
"Content-Transfer-Encoding: base64\r\n" .
|
||||
"Content-Disposition: attachment; filename=\"basics.php\"\r\n\r\n";
|
||||
$this->assertContains($expected, $result['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test send() with no template as both
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSendNoTemplateWithAttachmentsAsBoth() {
|
||||
$this->CakeEmail->transport('debug');
|
||||
$this->CakeEmail->from('cake@cakephp.org');
|
||||
$this->CakeEmail->to('cake@cakephp.org');
|
||||
$this->CakeEmail->subject('My title');
|
||||
$this->CakeEmail->emailFormat('both');
|
||||
$this->CakeEmail->attachments(array(CAKE . 'VERSION.txt'));
|
||||
$result = $this->CakeEmail->send('Hello');
|
||||
|
||||
$boundary = $this->CakeEmail->getBoundary();
|
||||
$this->assertContains('Content-Type: multipart/mixed; boundary="' . $boundary . '"', $result['headers']);
|
||||
$expected = "--$boundary\r\n" .
|
||||
"Content-Type: multipart/alternative; boundary=\"alt-$boundary\"\r\n" .
|
||||
"Content-Transfer-Encoding: 8bit\r\n" .
|
||||
"\r\n" .
|
||||
"Hello" .
|
||||
"\r\n" .
|
||||
"\r\n" .
|
||||
"\r\n" .
|
||||
"--$boundary\r\n" .
|
||||
"Content-Type: application/octet-stream\r\n" .
|
||||
"Content-Transfer-Encoding: base64\r\n" .
|
||||
"Content-Disposition: attachment; filename=\"VERSION.txt\"\r\n\r\n";
|
||||
$this->assertContains($expected, $result['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSendWithLog method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue