Skip to content

Instantly share code, notes, and snippets.

@zball zball/Test Example
Created Feb 2, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.