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() {
|
2016-12-11 11:02:40 +00:00
|
|
|
$handler = new WC_Log_Handler_Email();
|
2016-11-27 19:19:59 +00:00
|
|
|
$time = time();
|
|
|
|
|
2016-12-11 11:02:40 +00:00
|
|
|
$handler->handle( $time, 'emergency', 'msg_emergency', array() );
|
2016-11-27 19:19:59 +00:00
|
|
|
|
|
|
|
$mailer = tests_retrieve_phpmailer_instance();
|
|
|
|
|
|
|
|
$this->assertEquals(
|
2016-12-11 17:03:48 +00:00
|
|
|
'You have received 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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|