function testShouldSaveItemPrices() { $cart = new \Metator\Cart\Cart(); $cart->add(1, 9.99); $cart->add(2, 4.99); $id = $this->dataMapper->save($cart); $reloaded_cart = $this->dataMapper->load($id); $this->assertEquals(9.99, $reloaded_cart->price(1), 'should save item price'); $this->assertEquals(4.99, $reloaded_cart->price(2), 'should save item price'); }
function testShouldSaveCartAndItems() { $cart = new \Metator\Cart\Cart(); $cart->add(1, 9.99); $cart->add(2, 4.99); $cart->setQuantity(2, 2); $order = array('items' => $cart, 'created' => '0000-00-00 00:00:00'); $orderMapper = new DataMapper($this->db); $id = $orderMapper->save($order, null); $reloaded_order = $orderMapper->load($id); $this->assertEquals(array(1, 2), $reloaded_order['items']->items(), 'should save items'); }