public function testGetPrice() { $basket = new Basket(); $discount = new Discount(); $apple = new Product("Apple", 32, Product::UNIT_KG, $discount); $apple_one = new Item($apple, 3); $apple_two = new Item($apple, 2); $basket->addItem($apple_one); $basket->addItem($apple_two); $cashier = new Cashier(); $this->assertEquals((3 + 2) * 32, $cashier->getPrice($basket)); }
public function testAddProduct() { $basket = new Basket(); $discount = new Discount(); $apple = new Product("Apple", 32, Product::UNIT_KG, $discount); $apple_one = new Item($apple, 3); $apple_two = new Item($apple, 2); $basket->addItem($apple_one); $basket->addItem($apple_two); $items = $basket->getItems(); /* @var $item Item */ foreach ($items as $item) { $this->assertEquals($apple, $item->getProduct()); } $this->assertEquals(3 + 2, $item->getAmount()); }