Skip to content

Instantly share code, notes, and snippets.

@zball
Created February 2, 2016 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zball/65981fd8d239295a1348 to your computer and use it in GitHub Desktop.
Save zball/65981fd8d239295a1348 to your computer and use it in GitHub Desktop.
public function testCanUpdateProductAlreadyInCart()
{
$client = static::createClient();
$client->request('POST', '/api/carts');
$client->request('POST', '/api/products', [
'name' => 'Foo',
'unit_price' => '500'
]);
$client->request('POST', '/api/products', [
'name' => 'Bar',
'unit_price' => '200'
]);
$client->request('POST', '/api/carts/1/products/1');
$client->request('POST', '/api/carts/1/products/2');
$client->request('PUT', '/api/carts/1/products/1', ['quantity' => 3]);
$client->request('POST', '/api/carts/1/products/1');
$client->request('GET', '/api/carts/1');
$response = $client->getResponse()->getContent();
$cart = json_decode($response);
$this->assertCount(2, $cart->cart_items);
$this->assertEquals(4, $cart->cart_items[0]->quantity);
$this->assertEquals(1, $cart->cart_items[1]->quantity);
$this->assertEquals(2200, $cart->cart_total);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment