/** * Testing totals for sub sub items */ public function testSubItemsSubItemsTotal() { $item = $this->addItem(1, 11); $subItem = new \LukePOLO\LaraCart\CartItem('10', 'sub item item', 1, 2); $subItem->addSubItem(['items' => [new \LukePOLO\LaraCart\CartItem('10', 'sub item item', 1, 1)]]); $item->addSubItem(['items' => [$subItem]]); $this->assertEquals(3, $item->subItemsTotal(false)); $this->assertEquals(14, $item->subTotal(false)); $this->assertEquals(14, $item->price(false)); }
/** * Test Tax in case the sub sub item is untaxed but sub item is taxed. */ public function testAddTaxedSubSubItemUntaxedSubItemTaxed() { $item = $this->addItem(1, 3, true); $subItem = new \LukePOLO\LaraCart\CartItem('itemId', 'test sub item', 1, 10, [], true); $subItem->addSubItem(['items' => [new \LukePOLO\LaraCart\CartItem('itemId', 'test sub sub item', 1, 10, [], false)]]); $item->addSubItem(['items' => [$subItem]]); $this->assertEquals(23.0, $item->price(false)); $this->assertEquals('0.91', $this->laracart->taxTotal(false)); }