public function MailchimpEcommerceTest::testAddOrder in Mailchimp 8
Tests library function for adding an order.
File
- lib/
mailchimp-api-php/ tests/ MailchimpEcommerceTest.php, line 419
Class
- MailchimpEcommerceTest
- Mailchimp Ecommerce test library.
Namespace
Mailchimp\TestsCode
public function testAddOrder() {
$store_id = 'MC001';
$order_id = 'ord0001';
$customer = [
'id' => 'cust0005',
'email_address' => 'freddy@freddiesjokes.com',
'opt_in_status' => TRUE,
];
$order = [
'currency_code' => 'USD',
'order_total' => 12.45,
'lines' => [
'id' => 'LINE001',
'product_id' => 'PROD001',
'product_title' => "Freddie's Jokes",
'product_variant_id' => 'PROD001A',
'product_variant_title' => "Freddie's Jokes Volume 1",
'quantity' => 2,
'price' => 10,
],
];
$mc = new MailchimpEcommerce();
$mc
->addOrder($store_id, $order_id, $customer, $order);
$this
->assertEquals('POST', $mc
->getClient()->method);
$this
->assertEquals($mc
->getEndpoint() . '/ecommerce/stores/' . $store_id . '/orders', $mc
->getClient()->uri);
$this
->assertNotEmpty($mc
->getClient()->options['json']);
$request_body = $mc
->getClient()->options['json'];
$this
->assertEquals($order_id, $request_body->id);
$this
->assertEquals($customer['id'], $request_body->customer->id);
$this
->assertEquals($customer['email_address'], $request_body->customer->email_address);
$this
->assertEquals($customer['opt_in_status'], $request_body->customer->opt_in_status);
$this
->assertEquals($order['currency_code'], $request_body->currency_code);
$this
->assertEquals($order['order_total'], $request_body->order_total);
$this
->assertEquals($order['lines'], $request_body->lines);
$this
->assertEquals($order['lines']['id'], $request_body->lines['id']);
$this
->assertEquals($order['lines']['product_id'], $request_body->lines['product_id']);
$this
->assertEquals($order['lines']['product_title'], $request_body->lines['product_title']);
$this
->assertEquals($order['lines']['product_variant_id'], $request_body->lines['product_variant_id']);
$this
->assertEquals($order['lines']['product_variant_title'], $request_body->lines['product_variant_title']);
$this
->assertEquals($order['lines']['quantity'], $request_body->lines['quantity']);
$this
->assertEquals($order['lines']['price'], $request_body->lines['price']);
}