Example #1
0
 public function testRestore()
 {
     $item1 = new CartItem(array('name' => 'foo'));
     $item2 = new CartItem(array('name' => 'bar'));
     $storeGetReturn = array('id' => 'foo', 'items' => array($item1->toArray(), $item2->toArray()));
     $store = m::mock('Cart\\Storage\\Store');
     $store->shouldReceive('get')->times(1)->andReturn(serialize($storeGetReturn));
     $cart = new Cart('foo', $store);
     $cart->restore();
     $this->assertSame('foo', $cart->getId());
     $this->assertTrue($cart->totalUniqueItems() == 2);
     $this->assertTrue($cart->has($item1->id));
     $this->assertTrue($cart->has($item2->id));
 }