Ejemplo n.º 1
0
<?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}";
Ejemplo n.º 2
0
 public function testFactoryReturnsAnObject()
 {
     $car = CarFactory::create('carThatDoesNotExist');
     $this->assertEquals(0, $car->getPrice());
 }