Esempio n. 1
0
    $cars = array($porsche, $ford, $lexus, $mercedes);
    $output = "";
    foreach ($cars as $car) {
        $output = $output . "<div class='row'>\n            <div class='col-md-6'>\n                <img src=" . $car->getPicture() . ">\n            </div>\n                <div class='col-md-6'>\n                    <p>" . $car->getModel() . "</p>\n                    <p>By " . $car->getPrice() . "</p>\n                    <p>\$" . $car->getMiles() . "</p>\n                </div>\n            </div>\n            ";
    }
    return $output;
});
$app->get("/car_search", function () {
    return "\n        <!DOCTYPE html>\n        <html>\n        <head>\n              <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n              <title>Find a Car</title>\n\n        </head>\n        <body>\n            <div class='container'>\n                <h1>Find a Car!</h1>\n                <form action='/view_results'>\n                    <div class='form-group'>\n                        <label for='price'>Enter Maximum Price:</label>\n                        <input id='price' name='price' class='form-control' type='number'>\n                        <label for='mileage'>Enter Maximum Miles:</label>\n                        <input id='mileage' name='mileage' class='form-control' type='number'>\n\n                    </div>\n                    <button type='submit' class='btn-success'>Submit</button>\n                </form>\n            </div>\n        </body>\n        </html>\n        ";
});
$app->get("/view_results", function () {
    $porsche = new Car("/pictures/porsche.jpg", "2014 Porsche 911", null, 7864);
    //$porsche->make_model = "2014 Porsche 911";
    //$porsche->price = 114991;
    //$porsche->miles = 7864;
    $porsche->setModel("Acura");
    $porsche->setMiles(10000);
    $ford = new Car("/pictures/ford.jpg", "2001 Ford F450", 55995, 14241);
    /*$ford->make_model = "2011 Ford F450";
      $ford->price = 55995;
      $ford->miles = 14241;*/
    $lexus = new Car("/pictures/lexus.jpg", "2013 Lexus RX 350", 44700, 20000);
    /*$lexus->make_model = "2013 Lexus RX 350";
      $lexus->price = 44700;
      $lexus->miles = 20000;*/
    $mercedes = new Car("/pictures/mercedes.jpg", "Mercedes Benz CLS550", 39900, 37979);
    /*$mercedes->make_model = "Mercedes Benz CLS550";
      $mercedes->price = 39900;
      $mercedes->miles = 37979;*/
    $cars = array($porsche, $ford, $lexus, $mercedes);
    $cars_matching_search = array();
 /**
  * @test
  */
 public function shouldBeAbleToMerge()
 {
     // given
     $car = new Car();
     $car->deleteTableData()->yesImSure();
     $car->setBrand("Volkswagen");
     $car->setModel("Polo 1.6 TDI");
     $car->commit();
     $this->addCarProperty($car->getId(), "Hk", "75");
     $this->addCarProperty($car->getId(), "Mileage", "42000");
     $this->addCarProperty($car->getId(), "Year", "2010");
     $cars = new CarsWithProperties();
     // when
     $values = $cars->getValues();
     $firstCar = $values[0];
     // then
     $this->assertNotNull($firstCar['properties']);
 }