You are here

public function MailchimpEcommerceTest::testAddOrderLine in Mailchimp 8

Tests library function for adding an order line.

File

lib/mailchimp-api-php/tests/MailchimpEcommerceTest.php, line 527

Class

MailchimpEcommerceTest
Mailchimp Ecommerce test library.

Namespace

Mailchimp\Tests

Code

public function testAddOrderLine() {
  $store_id = 'MC001';
  $order_id = 'ord0001';
  $id = 'L002';
  $product = [
    'product_id' => 'PROD001',
    'product_variant_id' => "Freddie's Jokes",
    'quantity' => 1,
    'price' => 5,
  ];
  $mc = new MailchimpEcommerce();
  $mc
    ->addOrderLine($store_id, $order_id, $id, $product);
  $this
    ->assertEquals('POST', $mc
    ->getClient()->method);
  $this
    ->assertEquals($mc
    ->getEndpoint() . '/ecommerce/stores/' . $store_id . '/orders/' . $order_id . '/lines', $mc
    ->getClient()->uri);
  $this
    ->assertNotEmpty($mc
    ->getClient()->options['json']);
  $request_body = $mc
    ->getClient()->options['json'];
  $this
    ->assertEquals($id, $request_body->id);
  $this
    ->assertEquals($product['product_id'], $request_body->product_id);
  $this
    ->assertEquals($product['product_variant_id'], $request_body->product_variant_id);
  $this
    ->assertEquals($product['quantity'], $request_body->quantity);
  $this
    ->assertEquals($product['price'], $request_body->price);
}