You are here

public function CommerceMessageOrderHistoryTest::testOrderHistory in Commerce Message 7

Test order history programmatically.

File

./commerce_message.test, line 109

Class

CommerceMessageOrderHistoryTest
Class CommerceMessageOrderHistoryTest

Code

public function testOrderHistory() {
  $order = $this
    ->createDummyOrder();
  commerce_order_status_update($order, 'pending');
  commerce_order_status_update($order, 'completed');
  RulesLog::logger()
    ->checkLog();
  $messages = $this
    ->loadMessagesForOrder($order);
  $this
    ->assertEqual(4, count($messages));

  // Assert order created.
  $message = reset($messages);
  array_shift($messages);
  $this
    ->assertBundle($message, 'commerce_order_created');
  $this
    ->assertEqual('Order has been created.', $message
    ->getText(LANGUAGE_NONE));

  // Assert product added to cart.
  $message = reset($messages);
  array_shift($messages);
  $this
    ->assertBundle($message, 'commerce_order_cart_add');
  $this
    ->assertEqual('Product PROD-01 added to the cart.', $message
    ->getText(LANGUAGE_NONE));

  // Assert status updates.
  $message = reset($messages);
  array_shift($messages);
  $this
    ->assertBundle($message, 'commerce_order_state');
  $this
    ->assertEqual('Status has been set to Pending (previously: Shopping cart).', $message
    ->getText(LANGUAGE_NONE));
  $message = reset($messages);
  array_shift($messages);
  $this
    ->assertBundle($message, 'commerce_order_state');
  $this
    ->assertEqual('Status has been set to Completed (previously: Pending).', $message
    ->getText(LANGUAGE_NONE));
}