/** * testMessageRetrievalWithHelper method * * @return void */ public function testMessageRetrievalWithHelper() { App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS))); $timestamp = time(); $this->Controller->set('time', $timestamp); $this->Controller->set('title_for_layout', 'EmailTest'); $this->Controller->helpers = array('Time'); $this->Controller->EmailTest->to = '*****@*****.**'; $this->Controller->EmailTest->from = '*****@*****.**'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '*****@*****.**'; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = 'custom_helper'; $this->Controller->EmailTest->sendAs = 'text'; $this->Controller->EmailTest->delivery = 'DebugComp'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertTrue((bool) strpos($this->Controller->EmailTest->textMessage, 'Right now: ' . date('Y-m-d\\TH:i:s\\Z', $timestamp))); }
/** * testMessageRetrievalWithTemplate method * * @access public * @return void */ function testMessageRetrievalWithTemplate() { App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS))); $this->Controller->set('value', 22091985); $this->Controller->set('title_for_layout', 'EmailTest'); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '*****@*****.**'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '*****@*****.**'; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = 'custom'; $this->Controller->EmailTest->delivery = 'debug'; $text = <<<TEXTBLOC Here is your value: 22091985 This email was sent using the CakePHP Framework, http://cakephp.org. TEXTBLOC; $html = <<<HTMLBLOC <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> \t<title>EmailTest</title> </head> <body> \t<p>Here is your value: <b>22091985</b></p> \t<p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p> </body> </html> HTMLBLOC; $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertNull($this->Controller->EmailTest->htmlMessage); $this->Controller->EmailTest->sendAs = 'html'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertNull($this->Controller->EmailTest->textMessage); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); }