/** @test */ public function should_calculate_the_tax_for_basket_fixture_nine() { $basket = $this->fixtures->nine(); $total = $this->meta->generate($basket); $this->assertEquals(new Money(890, new Currency('GBP')), $total); }
/** @test */ public function should_calculate_the_number_of_taxable_products_for_basket_fixture_nine() { $basket = $this->fixtures->nine(); $total = $this->meta->generate($basket); $this->assertEquals(5, $total); }
/** @test */ public function should_process_basket_fixture_nine() { $order = $this->processor->process($this->fixtures->nine()); $meta = $order->meta(); $products = $order->products(); $this->assertInstanceOf('PhilipBrown\\Basket\\Order', $order); $this->assertEquals(new Money(1495, new Currency('GBP')), $meta['delivery']); $this->assertEquals(new Money(1500, new Currency('GBP')), $meta['discount']); $this->assertEquals(7, $meta['products_count']); $this->assertEquals(new Money(13943, new Currency('GBP')), $meta['subtotal']); $this->assertEquals(5, $meta['taxable']); $this->assertEquals(new Money(890, new Currency('GBP')), $meta['tax']); $this->assertEquals(new Money(14833, new Currency('GBP')), $meta['total']); $this->assertEquals(new Money(21448, new Currency('GBP')), $meta['value']); $this->assertEquals('0', $products[0]['sku']); $this->assertEquals('Back to the Future Blu-ray', $products[0]['name']); $this->assertEquals(new Money(1000, new Currency('GBP')), $products[0]['price']); $this->assertEquals(new UnitedKingdomValueAddedTax(), $products[0]['rate']); $this->assertEquals(1, $products[0]['quantity']); $this->assertEquals(false, $products[0]['freebie']); $this->assertEquals(true, $products[0]['taxable']); $this->assertEquals(new Money(0, new Currency('GBP')), $products[0]['delivery']); $this->assertEquals(new Collection(), $products[0]['coupons']); $this->assertEquals(new Collection(), $products[0]['tags']); $this->assertEquals(null, $products[0]['discount']); $this->assertEquals(null, $products[0]['category']); $this->assertEquals(new Money(0, new Currency('GBP')), $products[0]['total_discount']); $this->assertEquals(new Money(0, new Currency('GBP')), $products[0]['total_delivery']); $this->assertEquals(new Money(200, new Currency('GBP')), $products[0]['total_tax']); $this->assertEquals(new Money(1000, new Currency('GBP')), $products[0]['subtotal']); $this->assertEquals(new Money(1200, new Currency('GBP')), $products[0]['total']); $this->assertEquals('5', $products[1]['sku']); $this->assertEquals('Sega Mega Drive', $products[1]['name']); $this->assertEquals(new Money(4950, new Currency('GBP')), $products[1]['price']); $this->assertEquals(new UnitedKingdomValueAddedTax(), $products[1]['rate']); $this->assertEquals(1, $products[1]['quantity']); $this->assertEquals(false, $products[1]['freebie']); $this->assertEquals(true, $products[1]['taxable']); $this->assertEquals(new Money(0, new Currency('GBP')), $products[1]['delivery']); $this->assertEquals(new Collection(), $products[1]['coupons']); $this->assertEquals(new Collection(), $products[1]['tags']); $this->assertEquals(new ValueDiscount(new Money(1500, new Currency('GBP'))), $products[1]['discount']); $this->assertEquals(null, $products[1]['category']); $this->assertEquals(new Money(4950, new Currency('GBP')), $products[1]['total_value']); $this->assertEquals(new Money(1500, new Currency('GBP')), $products[1]['total_discount']); $this->assertEquals(new Money(0, new Currency('GBP')), $products[1]['total_delivery']); $this->assertEquals(new Money(690, new Currency('GBP')), $products[1]['total_tax']); $this->assertEquals(new Money(3450, new Currency('GBP')), $products[1]['subtotal']); $this->assertEquals(new Money(4140, new Currency('GBP')), $products[1]['total']); $this->assertEquals('8', $products[2]['sku']); $this->assertEquals('Junior Jordans', $products[2]['name']); $this->assertEquals(new Money(3999, new Currency('GBP')), $products[2]['price']); $this->assertEquals(new UnitedKingdomValueAddedTax(), $products[2]['rate']); $this->assertEquals(2, $products[2]['quantity']); $this->assertEquals(false, $products[2]['freebie']); $this->assertEquals(false, $products[2]['taxable']); $this->assertEquals(new Money(599, new Currency('GBP')), $products[2]['delivery']); $this->assertEquals(new Collection(), $products[2]['coupons']); $this->assertEquals(new Collection(), $products[2]['tags']); $this->assertEquals(null, $products[2]['discount']); $this->assertEquals(null, $products[2]['category']); $this->assertEquals(new Money(7998, new Currency('GBP')), $products[2]['total_value']); $this->assertEquals(new Money(0, new Currency('GBP')), $products[2]['total_discount']); $this->assertEquals(new Money(1198, new Currency('GBP')), $products[2]['total_delivery']); $this->assertEquals(new Money(0, new Currency('GBP')), $products[2]['total_tax']); $this->assertEquals(new Money(9196, new Currency('GBP')), $products[2]['subtotal']); $this->assertEquals(new Money(9196, new Currency('GBP')), $products[2]['total']); $this->assertEquals('9', $products[3]['sku']); $this->assertEquals('Gift Card', $products[3]['name']); $this->assertEquals(new Money(2500, new Currency('GBP')), $products[3]['price']); $this->assertEquals(new UnitedKingdomValueAddedTax(), $products[3]['rate']); $this->assertEquals(3, $products[3]['quantity']); $this->assertEquals(true, $products[3]['freebie']); $this->assertEquals(true, $products[3]['taxable']); $this->assertEquals(new Money(99, new Currency('GBP')), $products[3]['delivery']); $this->assertEquals(new Collection(), $products[3]['coupons']); $this->assertEquals(new Collection(), $products[3]['tags']); $this->assertEquals(null, $products[3]['discount']); $this->assertEquals(null, $products[3]['category']); $this->assertEquals(new Money(7500, new Currency('GBP')), $products[3]['total_value']); $this->assertEquals(new Money(0, new Currency('GBP')), $products[3]['total_discount']); $this->assertEquals(new Money(297, new Currency('GBP')), $products[3]['total_delivery']); $this->assertEquals(new Money(0, new Currency('GBP')), $products[3]['total_tax']); $this->assertEquals(new Money(297, new Currency('GBP')), $products[3]['subtotal']); $this->assertEquals(new Money(297, new Currency('GBP')), $products[3]['total']); }