|
|
@ -93,26 +93,16 @@ class BaseMailerTest extends TestCase |
|
|
|
$this->assertTrue(is_object($view), 'Unable to get default view!'); |
|
|
|
$this->assertTrue(is_object($view), 'Unable to get default view!'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testComposeMessage() |
|
|
|
public function testCreateMessage() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$mailer = new Mailer(); |
|
|
|
$mailer = new Mailer(); |
|
|
|
$message = $mailer->message(); |
|
|
|
$message = $mailer->compose(); |
|
|
|
$this->assertTrue(is_object($message), 'Unable to create message instance!'); |
|
|
|
$this->assertTrue(is_object($message), 'Unable to create message instance!'); |
|
|
|
$this->assertEquals($mailer->messageClass, get_class($message), 'Invalid message class!'); |
|
|
|
$this->assertEquals($mailer->messageClass, get_class($message), 'Invalid message class!'); |
|
|
|
|
|
|
|
|
|
|
|
$messageConfig = array( |
|
|
|
|
|
|
|
'id' => 'test-id', |
|
|
|
|
|
|
|
'encoding' => 'test-encoding', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$message = $mailer->message($messageConfig); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($messageConfig as $name => $value) { |
|
|
|
|
|
|
|
$this->assertEquals($value, $message->$name, 'Unable to apply message config!'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @depends testComposeMessage |
|
|
|
* @depends testCreateMessage |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function testDefaultMessageConfig() |
|
|
|
public function testDefaultMessageConfig() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -135,7 +125,7 @@ class BaseMailerTest extends TestCase |
|
|
|
$messageConfig = array_merge($notPropertyConfig, $propertyConfig); |
|
|
|
$messageConfig = array_merge($notPropertyConfig, $propertyConfig); |
|
|
|
$mailer->messageConfig = $messageConfig; |
|
|
|
$mailer->messageConfig = $messageConfig; |
|
|
|
|
|
|
|
|
|
|
|
$message = $mailer->message(); |
|
|
|
$message = $mailer->compose(); |
|
|
|
|
|
|
|
|
|
|
|
foreach ($notPropertyConfig as $name => $value) { |
|
|
|
foreach ($notPropertyConfig as $name => $value) { |
|
|
|
$this->assertEquals($value, $message->{'_' . $name}); |
|
|
|
$this->assertEquals($value, $message->{'_' . $name}); |
|
|
@ -165,48 +155,58 @@ class BaseMailerTest extends TestCase |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @depends testComposeMessage |
|
|
|
|
|
|
|
* @depends testRender |
|
|
|
* @depends testRender |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function testComposeSetupMethods() |
|
|
|
public function testRenderLayout() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$mailer = $this->getTestMailComponent(); |
|
|
|
$mailer = $this->getTestMailComponent(); |
|
|
|
$mailer->textLayout = false; |
|
|
|
|
|
|
|
|
|
|
|
$filePath = $this->getTestFilePath(); |
|
|
|
|
|
|
|
|
|
|
|
$viewName = 'test_view'; |
|
|
|
$viewName = 'test_view'; |
|
|
|
$viewFileName = $this->getTestFilePath() . DIRECTORY_SEPARATOR . $viewName . '.php'; |
|
|
|
$viewFileName = $filePath . DIRECTORY_SEPARATOR . $viewName . '.php'; |
|
|
|
$viewFileContent = 'view file content'; |
|
|
|
$viewFileContent = 'view file content'; |
|
|
|
file_put_contents($viewFileName, $viewFileContent); |
|
|
|
file_put_contents($viewFileName, $viewFileContent); |
|
|
|
|
|
|
|
|
|
|
|
$messageConfig = array( |
|
|
|
$layoutName = 'test_layout'; |
|
|
|
'renderText' => [$viewName], |
|
|
|
$layoutFileName = $filePath . DIRECTORY_SEPARATOR . $layoutName . '.php'; |
|
|
|
); |
|
|
|
$layoutFileContent = 'Begin Layout <?php echo $content; ?> End Layout';
|
|
|
|
$message = $mailer->message($messageConfig); |
|
|
|
file_put_contents($layoutFileName, $layoutFileContent); |
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($viewFileContent, $message->_text); |
|
|
|
$renderResult = $mailer->render($viewName, [], $layoutName); |
|
|
|
|
|
|
|
$this->assertEquals('Begin Layout ' . $viewFileContent . ' End Layout', $renderResult); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* @depends testCreateMessage |
|
|
|
* @depends testRender |
|
|
|
* @depends testRender |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function testRenderLayout() |
|
|
|
public function testCompose() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$mailer = $this->getTestMailComponent(); |
|
|
|
$mailer = $this->getTestMailComponent(); |
|
|
|
|
|
|
|
$mailer->htmlLayout = false; |
|
|
|
|
|
|
|
$mailer->textLayout = false; |
|
|
|
|
|
|
|
|
|
|
|
$filePath = $this->getTestFilePath(); |
|
|
|
$htmlViewName = 'test_html_view'; |
|
|
|
|
|
|
|
$htmlViewFileName = $this->getTestFilePath() . DIRECTORY_SEPARATOR . $htmlViewName . '.php'; |
|
|
|
|
|
|
|
$htmlViewFileContent = 'HTML <b>view file</b> content'; |
|
|
|
|
|
|
|
file_put_contents($htmlViewFileName, $htmlViewFileContent); |
|
|
|
|
|
|
|
|
|
|
|
$viewName = 'test_view'; |
|
|
|
$textViewName = 'test_text_view'; |
|
|
|
$viewFileName = $filePath . DIRECTORY_SEPARATOR . $viewName . '.php'; |
|
|
|
$textViewFileName = $this->getTestFilePath() . DIRECTORY_SEPARATOR . $textViewName . '.php'; |
|
|
|
$viewFileContent = 'view file content'; |
|
|
|
$textViewFileContent = 'Plain text view file content'; |
|
|
|
file_put_contents($viewFileName, $viewFileContent); |
|
|
|
file_put_contents($textViewFileName, $textViewFileContent); |
|
|
|
|
|
|
|
|
|
|
|
$layoutName = 'test_layout'; |
|
|
|
$message = $mailer->compose([ |
|
|
|
$layoutFileName = $filePath . DIRECTORY_SEPARATOR . $layoutName . '.php'; |
|
|
|
'html' => $htmlViewName, |
|
|
|
$layoutFileContent = 'Begin Layout <?php echo $content; ?> End Layout';
|
|
|
|
'text' => $textViewName, |
|
|
|
file_put_contents($layoutFileName, $layoutFileContent); |
|
|
|
]); |
|
|
|
|
|
|
|
$this->assertEquals($htmlViewFileContent, $message->_html, 'Unable to render html!'); |
|
|
|
|
|
|
|
$this->assertEquals($textViewFileContent, $message->_text, 'Unable to render text!'); |
|
|
|
|
|
|
|
|
|
|
|
$renderResult = $mailer->render($viewName, [], $layoutName); |
|
|
|
$message = $mailer->compose($htmlViewName); |
|
|
|
$this->assertEquals('Begin Layout ' . $viewFileContent . ' End Layout', $renderResult); |
|
|
|
$this->assertEquals($htmlViewFileContent, $message->_html, 'Unable to render html by direct view!'); |
|
|
|
|
|
|
|
$this->assertEquals(strip_tags($htmlViewFileContent), $message->_text, 'Unable to render text by direct view!'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|