Adding test cases for using helpers in nested elements from email

templates.  Closes #1355
This commit is contained in:
mark_story 2010-12-09 22:34:20 -05:00
parent a830632071
commit d7e62b88bc
3 changed files with 27 additions and 13 deletions

View file

@ -629,22 +629,30 @@ HTMLBLOC;
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . '</pre>'; $expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . '</pre>';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin')); $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
}
return; /**
* test that elements used in email templates get helpers.
*
* @return void
*/
function testTemplateNestedElements() {
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake SMTP test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$text = <<<TEXTBLOC $this->Controller->EmailTest->delivery = 'debug';
$this->Controller->EmailTest->messageId = false;
$this->Controller->EmailTest->layout = 'default';
$this->Controller->EmailTest->template = 'nested_element';
$this->Controller->EmailTest->sendAs = 'html';
$this->Controller->helpers = array('Html');
This element has some text that is just too wide to comply with email $this->Controller->EmailTest->send();
standards. $result = $this->Controller->Session->read('Message.email.message');
This is the body of the message $this->assertPattern('/Test/', $result);
$this->assertPattern('/http\:\/\/example\.com/', $result);
This email was sent using the CakePHP Framework, http://cakephp.org.
TEXTBLOC;
$this->Controller->EmailTest->sendAs = 'text';
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . "\n" . '</pre>';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'wide', 'default'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
} }
/** /**

View file

@ -0,0 +1,3 @@
Before the element.
<?php echo $this->element('html_call'); ?>
After the element.

View file

@ -0,0 +1,3 @@
<?php
echo $this->Html->link('Test', 'http://example.com');
?>