Test WC_Email::style_inline()

This commit is contained in:
Claudio Sanches 2020-01-29 17:07:18 -03:00
parent a52287c824
commit 052fbfcb8c
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,5 @@
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body style="padding: 0;"><p class="text" style='color: #3c3c3c; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;'>Hello World!</p></body>
</html>

View File

@ -0,0 +1,53 @@
<?php
/**
* Test for the email class.
* @package WooCommerce\Tests\Emails
*/
/**
* WC_Tests_WC_Emails.
*
* @covers \WC_Email
*/
class WC_Tests_WC_Emails extends WC_Unit_Test_Case {
/**
* Setup tests.
*/
public function setUp() {
parent::setUp();
// Load email classes.
$emails = new WC_Emails();
$emails->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( '<p class="text">Hello World!</p>' );
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( '<p class="text">Hello World!</p>' );
$expected = '<p class="text">Hello World!</p>';
$this->assertEquals( $expected, $result );
}
}