Skip to content

Instantly share code, notes, and snippets.

@Diastro
Created March 20, 2014 04:31
Show Gist options
  • Select an option

  • Save Diastro/9657292 to your computer and use it in GitHub Desktop.

Select an option

Save Diastro/9657292 to your computer and use it in GitHub Desktop.
<?php
// Setup
$I = new Api($scenario);
$I->wantTo('add a new product');
$I->haveHttpHeader('Authorization-User','admin');
$I->haveHttpHeader('Authorization-Password','test');
// Creating a new product
$variant = array('size' => 'medium',
'sku' => '11b02020202-M',
'quantity' => "2",
'inventorystatus' => 'In stock');
$product = array('name' => 'ProduitAcceptance',
'description' => 'Produit bidon pour les tests d\'acceptance.',
'idFamily' => 1,
'Price' => 1000,
'variants' => $variant
);
$I->haveHttpHeader('Content-Type','application/json');
$I->sendPOST('/products', $product);
// Validation
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array('status_code' => 201));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment