You are here

public function MailchimpEcommerceTestCase::testAddOrder in Mailchimp E-Commerce 7

Tests adding an order to Mailchimp.

File

tests/mailchimp_ecommerce.test, line 90
Test class and methods for the Mailchimp eCommerce module.

Class

MailchimpEcommerceTestCase
Tests for Mailchimp eCommerce core integration.

Code

public function testAddOrder() {
  $store_id = 1;
  $order_id = 1;
  $customer = [
    'id' => 1,
    'email_address' => 'testuser@example.com',
    'first_name' => 'Test',
    'last_name' => 'User',
  ];
  $order = [
    'currency_code' => 'USD',
    'order_total' => 29.98,
    'lines' => [
      (object) [
        'id' => 1,
        'product_id' => 11,
        'product_variant_id' => 11,
        'quantity' => 1,
        'price' => 9.99,
      ],
      'lines' => [
        (object) [
          'id' => 2,
          'product_id' => 12,
          'product_variant_id' => 12,
          'quantity' => 1,
          'price' => 19.99,
        ],
      ],
    ],
  ];
  mailchimp_ecommerce_add_order($order_id, $customer, $order);

  /* @var \Mailchimp\MailchimpEcommerce $mc_ecommerce */
  $mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
  $saved_order = $mc_ecommerce
    ->getOrder($store_id, $order_id);
  $this
    ->assertEqual($saved_order->id, $order_id);
  $this
    ->assertEqual($saved_order->currency_code, $order['currency_code']);
  $this
    ->assertEqual($saved_order->order_total, $order['order_total']);
}