public function testRestoreExceptions() { $exceptionCounter = 0; $store = m::mock('Cart\\Storage\\Store'); $store->shouldReceive('get')->times(6)->andReturn('!foo!', serialize('bar'), serialize(array('id' => 'foo')), serialize(array('items' => array())), serialize(array('id' => array(), 'items' => array())), serialize(array('items' => 'foo', 'id' => 'foo'))); $cart = new Cart('foo', $store); for ($i = 1; $i <= 6; $i++) { try { $cart->restore(); } catch (CartRestoreException $e) { $exceptionCounter++; } } $this->assertEquals($exceptionCounter, 6); }