woocommerce/tests/unit-tests/log/log-handler-email.php

40 lines
806 B
PHP
Raw Normal View History

2016-11-27 19:19:59 +00:00
<?php
/**
* Class WC_Tests_Log_Handler_Email
* @package WooCommerce\Tests\Log
* @since 2.8
*/
class WC_Tests_Log_Handler_Email extends WC_Unit_Test_Case {
function setUp() {
parent::setUp();
reset_phpmailer_instance();
}
function tearDown() {
reset_phpmailer_instance();
parent::tearDown();
}
/**
* Test handle writes to database correctly.
*
* @since 2.8
*/
public function test_handle() {
$handler = new WC_Log_Handler_Email();
2016-11-27 19:19:59 +00:00
$time = time();
$handler->handle( $time, 'emergency', 'msg_emergency', array() );
2016-11-27 19:19:59 +00:00
$mailer = tests_retrieve_phpmailer_instance();
$this->assertEquals(
'You have recieved the following WooCommerce log message:' . PHP_EOL . PHP_EOL . date( 'c', $time ) . ' EMERGENCY msg_emergency' . PHP_EOL,
2016-11-27 19:19:59 +00:00
$mailer->get_sent()->body
);
}
}