Added a few exceptions that will be thrown at the time of errors. Makes for easier debugging. Also updated README accordingly

This commit is contained in:
Rob Gloudemans
2013-07-27 17:46:57 +02:00
parent 042ab7a45a
commit 628244bdcf
8 changed files with 103 additions and 2 deletions

View File

@@ -233,4 +233,46 @@ class CartTest extends TestCase {
$this->assertEquals($search, array($row1));
}
/**
* @expectedException Gloudemans\Shoppingcart\Exceptions\ShoppingcartInstanceException
*/
public function testShoppingcartInstanceException()
{
Cart::instance();
}
/**
* @expectedException Gloudemans\Shoppingcart\Exceptions\ShoppingcartInvalidItemException
*/
public function testShoppingcartInvalidItemException()
{
Cart::add(1);
}
/**
* @expectedException Gloudemans\Shoppingcart\Exceptions\ShoppingcartInvalidQtyException
*/
public function testShoppingcartInvalidQtyException()
{
Cart::add(1, 'Product 1', 'nonnumeric', 10.00);
}
/**
* @expectedException Gloudemans\Shoppingcart\Exceptions\ShoppingcartInvalidPriceException
*/
public function testShoppingcartInvalidPriceException()
{
Cart::add(1, 'Product 1', 1, 'nonnumeric');
}
/**
* @expectedException Gloudemans\Shoppingcart\Exceptions\ShoppingcartInvalidRowIDException
*/
public function testShoppingcartInvalidRowIDException()
{
Cart::add(1, 'Product 1', 1, 10.00);
Cart::update('nonexistingrowid', 2);
}
}