diff --git a/tests/data/sample-email.html b/tests/data/sample-email.html new file mode 100644 index 00000000000..144b4c7b845 --- /dev/null +++ b/tests/data/sample-email.html @@ -0,0 +1,5 @@ + + + +

Hello World!

+ diff --git a/tests/unit-tests/email/emails.php b/tests/unit-tests/email/emails.php new file mode 100644 index 00000000000..3525c0e7153 --- /dev/null +++ b/tests/unit-tests/email/emails.php @@ -0,0 +1,53 @@ +init(); + } + + /** + * Test get and set items. + */ + public function test_style_inline() { + $email = new WC_Email(); + + // Test HTML email with inline styles. + $email->email_type = 'html'; + + // Set some content to get converted. + $result = $email->style_inline( '

Hello World!

' ); + + ob_start(); + include WC_Unit_Tests_Bootstrap::instance()->tests_dir . '/data/sample-email.html'; + $expected = ob_get_clean(); + + $this->assertEquals( $expected, $result ); + + // Test plain text email. + $email->email_type = 'plain'; + + // Set some content to get converted. + $result = $email->style_inline( '

Hello World!

' ); + $expected = '

Hello World!

'; + + $this->assertEquals( $expected, $result ); + } + +}