You are here

public function CommerceMessageOrderNotificationTest::testOrderNotificationMessageContent in Commerce Message 7

Test the order message's content.

File

./commerce_message.test, line 218

Class

CommerceMessageOrderNotificationTest
Class CommerceMessageOrderNotificationTest

Code

public function testOrderNotificationMessageContent() {
  $order = $this
    ->createDummyOrder();
  $message = message_create('commerce_order_order_confirmation', array(), $this->store_admin);
  $message
    ->wrapper()->message_commerce_order = $order;
  $message
    ->save();
  $mid = $message->mid;

  // Reload the message to see it was saved.
  $message = message_load($mid);
  $this
    ->assertTrue(!empty($message->mid), t('Message was saved to the database.'));
  $message = $message
    ->buildContent();
  global $language;
  $url_options = array(
    'absolute' => TRUE,
    'language' => $language,
  );
  $this
    ->assertEqual(t('Order @order_id at @site', array(
    '@order_id' => $order->order_id,
    '@site' => variable_get('site_name', 'Drupal'),
  )), $message['message__message_text__0']['#markup']);
  $body = t('Thanks for your order @order_id at @site.

If this is your first order with us, you will receive a separate e-mail with login instructions. You can view your order history with us at any time by logging into our website at:

@login-url

You can find the status of your current order at:

@order-view

Please contact us if you have any questions about your order.', array(
    '@order_id' => $order->order_id,
    '@site' => variable_get('site_name', 'Drupal'),
    '@login-url' => url('user', $url_options),
    '@order-view' => url('user/' . $order->uid . '/orders/' . $order->order_id, $url_options),
  ));
  $this
    ->assertEqual($body, $message['message__message_text__1']['#markup']);
}