Ejemplo n.º 1
0
 public function testBoth()
 {
     $order = Cart::getOrder();
     $item = $order->addItem(array("name" => "test product", "description" => "Product description...", "price" => 100, "quantity" => 1, "taxable" => true, "identifier" => 1));
     $order->editShippingAddress(TestFactory::createQuebecAddress());
     $order->addDiscountCode(array("amount" => 5, "title" => "Promo 5 dollars", "type" => OrderDiscountCode::TYPE_FIXED));
     $order->addDiscountCode(array("amount" => 10, "title" => "Promo 10%", "type" => OrderDiscountCode::TYPE_PERCENT));
     $this->assertEquals(15, Cart::getOrder()->getAmountDiscounts());
     $this->assertEquals(85, Cart::getOrder()->getAmountSubTotal());
 }
Ejemplo n.º 2
0
 public function testTypeHarmonized()
 {
     $order = Cart::getOrder();
     $item = $order->addItem(array("name" => "test product", "description" => "Product description...", "price" => 100, "quantity" => 1, "taxable" => true, "identifier" => 1));
     $order->editShippingAddress(TestFactory::createOntarioAddress());
     $GST = $order->getTaxByTitle("GST");
     $HST = $order->getTaxByTitle("HST");
     $this->assertEquals(0, $GST->getAmount());
     $this->assertEquals(13, $HST->getAmount());
     $this->assertEquals(13, $order->getAmountTaxes());
     $this->assertEquals(13, $item->getAmountTaxes());
 }
Ejemplo n.º 3
0
 public function testFixed()
 {
     $order = Cart::getOrder();
     $item = $order->addItem(array("name" => "test product", "description" => "Product description...", "price" => 100, "quantity" => 1, "taxable" => true, "identifier" => 1));
     $item2 = $order->addItem(array("name" => "test product 2", "description" => "Product description...", "price" => 50, "quantity" => 2, "taxable" => true, "identifier" => 2));
     $order->editShippingAddress(TestFactory::createQuebecAddress());
     $this->assertEquals(200, Cart::getOrder()->getAmountSubTotal());
     $order->createReturn(array("items" => array(array("identifier" => 2, "quantity" => 1)), "note" => "Client not satisfied with quality"));
     $this->assertEquals(150, Cart::getOrder()->getAmountSubTotal());
     $order->createReturn(array("items" => array(array("identifier" => 1, "quantity" => 1)), "note" => "Client not satisfied with quality"));
     $this->assertEquals(50, Cart::getOrder()->getAmountSubTotal());
     $this->setExpectedException('Exception', '', Order::EXCEPTION_RETURN_ITEM_QUANTITY);
     $order->createReturn(array("items" => array(array("identifier" => 2, "quantity" => 2)), "note" => "Client not satisfied with quality"));
 }
Ejemplo n.º 4
0
 public function testShippingAddress()
 {
     Cart::getOrder()->editShippingAddress(TestFactory::createQuebecAddress());
 }
Ejemplo n.º 5
0
 /**
  * @param array $tests
  */
 public function __construct(array $tests = array())
 {
     $this->tests = count($tests) > 0 ? $tests : TestFactory::makeAll();
 }