Permalink
Browse files

Added test for fallback

  • Loading branch information...
No3x committed Oct 4, 2018
1 parent cccfcbf commit 0f029bea085cb027b46831a8bddd8ae14b9ab0d6
Showing with 26 additions and 0 deletions.
  1. +26 −0 tests/phpunit/unit/WPML_MailRenderer_Test.php
@@ -61,6 +61,32 @@ public function test_print_mail_json() {
$this->mailServiceMock->mockery_verify();
}
public function test_print_mail_json_fallback_to_raw() {
$this->mailServiceMock = Mockery::mock('No3x\WPML\Model\IMailService');
/** @var $mail WPML_Mail */
$mail = (new WPML_MailExtractor())->extract(WPMailArrayBuilder::aMail()
->withSubject("Test")
->withTo("example@exmple.com")
->withHeaders("Content-Type: text/html")
->withMessage("Message")
->build());
$mail->set_mail_id($this->id);
$mail->set_plugin_version('1.8.5');
$mail->set_timestamp('2018-09-24 16:02:11');
$mail->set_host('127.0.0.1');
$mail->set_error('a');
$this->mailServiceMock->shouldReceive('find_one')
->times(1)
->with( $this->id )
->andReturn( $mail );
$this->mailRenderer = new WPML_MailRenderer($this->mailServiceMock);
$this->assertContains("Fallback", $this->mailRenderer->render($this->id, WPML_MailRenderer::FORMAT_JSON));
$this->mailServiceMock->mockery_verify();
}
public function test_print_mail_raw() {
$expected = '<span class="title">Time: </span>2018-09-24 16:02:11<span class="title">Receiver: </span>example@exmple.com<span class="title">Subject: </span>Test<span class="title">Message: </span>&lt;b&gt;Bold&lt;/b&gt;<span class="title">Headers: </span>From: &quot;admin&quot; ,\nCc: example2@example.com,\nReply-To: admin <span class="title">Attachments: </span><span class="title">Error: </span><i class="fa fa-exclamation-circle" title="a"></i>';
$actual = $this->mailRenderer->render($this->id, WPML_MailRenderer::FORMAT_RAW);

0 comments on commit 0f029be

Please sign in to comment.