public function MailchimpEcommerceTest::testAddProduct in Mailchimp 8
Test adding a product.
File
- lib/
mailchimp-api-php/ tests/ MailchimpEcommerceTest.php, line 585
Class
- MailchimpEcommerceTest
- Mailchimp Ecommerce test library.
Namespace
Mailchimp\TestsCode
public function testAddProduct() {
$store_id = 'MC001';
$id = 'sku0001';
$title = 'Test Product 001';
$url = 'http://example.org/';
$variant_1 = (object) [
'id' => 'PROD001A',
'title' => "Freddie's Jokes Volume 1",
];
$variants = [
$variant_1,
];
$mc = new MailchimpEcommerce();
$mc
->addProduct($store_id, $id, $title, $url, $variants);
$this
->assertEquals('POST', $mc
->getClient()->method);
$this
->assertEquals($mc
->getEndpoint() . '/ecommerce/stores/' . $store_id . '/products', $mc
->getClient()->uri);
$this
->assertNotEmpty($mc
->getClient()->options['json']);
$request_body = $mc
->getClient()->options['json'];
$this
->assertEquals($id, $request_body->id);
$this
->assertEquals($title, $request_body->title);
$this
->assertEquals($variant_1->id, $request_body->variants[0]->id);
$this
->assertEquals($variant_1->title, $request_body->variants[0]->title);
}