public function MailchimpEcommerceTest::testAddCartLine in Mailchimp 8
Tests library function for adding a line item to a cart.
File
- lib/
mailchimp-api-php/ tests/ MailchimpEcommerceTest.php, line 238
Class
- MailchimpEcommerceTest
- Mailchimp Ecommerce test library.
Namespace
Mailchimp\TestsCode
public function testAddCartLine() {
$store_id = 'MC001';
$cart_id = 'cart0001';
$id = 'L001';
$product = [
'product_id' => 'PROD001',
'product_variant_id' => "Freddie's Jokes",
'quantity' => 1,
'price' => 5,
];
$mc = new MailchimpEcommerce();
$mc
->addCartLine($store_id, $cart_id, $id, $product);
$this
->assertEquals('POST', $mc
->getClient()->method);
$this
->assertEquals($mc
->getEndpoint() . '/ecommerce/stores/' . $store_id . '/carts/' . $cart_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);
}