mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fixes in render. Tests added.
This commit is contained in:
parent
d0f1843dd5
commit
6e15945e73
2 changed files with 57 additions and 4 deletions
|
@ -143,6 +143,13 @@ class CakeEmail {
|
|||
*/
|
||||
protected $_template = '';
|
||||
|
||||
/**
|
||||
* View for render
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_viewRender = 'View';
|
||||
|
||||
/**
|
||||
* Text message
|
||||
*
|
||||
|
@ -651,6 +658,16 @@ class CakeEmail {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set view class for render
|
||||
*
|
||||
* @param string $viewClass
|
||||
* @return void
|
||||
*/
|
||||
public function setViewRender($viewClass) {
|
||||
$this->_viewRender = $viewClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the email format
|
||||
*
|
||||
|
@ -823,6 +840,7 @@ class CakeEmail {
|
|||
$this->_headers = array();
|
||||
$this->_layout = 'default';
|
||||
$this->_template = '';
|
||||
$this->_viewRender = 'View';
|
||||
$this->_textMessage = '';
|
||||
$this->_htmlMessage = '';
|
||||
$this->_message = '';
|
||||
|
@ -1008,16 +1026,16 @@ class CakeEmail {
|
|||
* @access private
|
||||
*/
|
||||
function _render($content) {
|
||||
$viewClass = $this->Controller->view;
|
||||
$viewClass = $this->_viewRender;
|
||||
|
||||
if ($viewClass !== 'View') {
|
||||
list($plugin, $viewClass) = pluginSplit($viewClass);
|
||||
$viewClass = $viewClass . 'View';
|
||||
App::import('View', $this->Controller->view);
|
||||
App::import('View', $this->_viewRender);
|
||||
}
|
||||
|
||||
$View = new $viewClass($this->Controller);
|
||||
$View->layout = $this->layout;
|
||||
$View = new $viewClass(null);
|
||||
$View->layout = $this->_layout;
|
||||
$msg = array();
|
||||
|
||||
$content = implode("\n", $content);
|
||||
|
|
|
@ -102,6 +102,20 @@ class CakeEmailTest extends CakeTestCase {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->CakeEmail = new TestCakeEmail();
|
||||
|
||||
App::build(array(
|
||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -381,6 +395,27 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->assertTrue((bool)strpos(DebugTransport::$lastHeader, 'To: '));
|
||||
}
|
||||
|
||||
/**
|
||||
* testSendRender method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSendRender() {
|
||||
$this->CakeEmail->reset();
|
||||
$this->CakeEmail->setTransport('debug');
|
||||
DebugTransport::$includeAddresses = true;
|
||||
|
||||
$this->CakeEmail->setFrom('cake@cakephp.org');
|
||||
$this->CakeEmail->setTo(array('you@cakephp.org' => 'You'));
|
||||
$this->CakeEmail->setSubject('My title');
|
||||
$this->CakeEmail->setLayout('default', 'default');
|
||||
$result = $this->CakeEmail->send();
|
||||
|
||||
$this->assertTrue((bool)strpos(DebugTransport::$lastEmail, 'This email was sent using the CakePHP Framework'));
|
||||
$this->assertTrue((bool)strpos(DebugTransport::$lastHeader, 'Message-ID: '));
|
||||
$this->assertTrue((bool)strpos(DebugTransport::$lastHeader, 'To: '));
|
||||
}
|
||||
|
||||
/**
|
||||
* testReset method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue