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 testTypeNormal()
 {
     $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());
     $PST = $order->getTaxByTitle("PST");
     $GST = $order->getTaxByTitle("GST");
     $this->assertEquals(5, $GST->getAmount());
     $this->assertEquals(9.98, $PST->getAmount());
     $this->assertEquals(14.98, $order->getAmountTaxes());
     $this->assertEquals(14.98, $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());
 }