Add unit test

This commit is contained in:
Amine Ben hammou
2019-11-04 12:27:44 +01:00
committed by Jack Kitterhing
parent 9f594f7666
commit 2b34c20eca

View File

@ -0,0 +1,44 @@
<?php
namespace MailPoet\WooCommerce;
use Codeception\Stub;
use MailPoet\Settings\SettingsController;
use MailPoet\WP\Functions as WPFunctions;
class TransactionalEmailsTest extends \MailPoetUnitTest {
function testGetEmailHeadings() {
$wp = Stub::make(new WPFunctions, [
'getOption' => function($name) {
if ($name === 'woocommerce_new_order_settings')
return ['heading' => '{site_title}: New Order: #{order_number}'];
if ($name === 'woocommerce_customer_completed_order_settings')
return ['heading' => 'Thanks for shopping at {site_address}'];
if ($name === 'woocommerce_customer_note_settings')
return ['heading' => 'Note added to order #{order_number} - {order_date}'];
if ($name === 'blogname')
return 'Test';
return false;
},
'homeUrl' => 'http://test.loc',
'wpSpecialcharsDecode' => function($text) {
expect($text)->equals('Test');
return $text;
},
'wpParseUrl' => function($url) {
expect($url)->equals('http://test.loc');
return 'test.loc';
},
]);
$settings = Stub::make(SettingsController::class);
$transactional_emails = new TransactionalEmails($wp, $settings);
expect($transactional_emails->getEmailHeadings())->equals([
'new_account' => 'Test: New Order: #0001',
'processing_order' => 'Thank you for your order',
'completed_order' => 'Thanks for shopping at test.loc',
'customer_note' => 'Note added to order #0001 - ' . date('Y-m-d'),
]);
}
}