<?php require 'cart.php'; $cart = array(CarFactory::create('Bmw'), CarFactory::create('xyzwtf')); foreach ($cart as $car) { $totalPrice += $car->getPrice(); } echo "The total price for all the cars found in Cart is: {$totalPrice}";
public function testFactoryReturnsAnObject() { $car = CarFactory::create('carThatDoesNotExist'); $this->assertEquals(0, $car->getPrice()); }