public function MailchimpEcommerceTest::testAddProductVariant in Mailchimp 8
Test adding a product variant.
File
- lib/
mailchimp-api-php/ tests/ MailchimpEcommerceTest.php, line 666
Class
- MailchimpEcommerceTest
- Mailchimp Ecommerce test library.
Namespace
Mailchimp\TestsCode
public function testAddProductVariant() {
$store_id = 'MC001';
$product_id = 'sku0001';
$params = [
'id' => 'var001',
'title' => 'Var Title',
];
$mc = new MailchimpEcommerce();
$mc
->addProductVariant($store_id, $product_id, $params);
$this
->assertEquals('POST', $mc
->getClient()->method);
$this
->assertEquals($mc
->getEndpoint() . '/ecommerce/stores/' . $store_id . '/products/' . $product_id . '/variants', $mc
->getClient()->uri);
$this
->assertNotEmpty($mc
->getClient()->options['json']);
$request_body = $mc
->getClient()->options['json'];
$this
->assertEquals($params['id'], $request_body->id);
$this
->assertEquals($params['title'], $request_body->title);
}