public function testCarPartsFactoryCreateEngineCalled() { $hybridEngine = new HybridEngine(); $factoryStub = $this->getMock('HybridCarPartsFactory'); $factoryStub->expects($this->once())->method('createEngine')->will($this->returnValue($hybridEngine)); $car = new Car($factoryStub); $car->start(); }
<?php require 'taxiClass.php'; $yellow_taxi = new Car(); if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; switch ($action) { case 'engine': $yellow_taxi->start(); break; case 'run': $yellow_taxi->run(); break; case 'stop': $yellow_taxi->stop(); break; default: # code... break; } } ?> <html> <body> <form method="post" action="taxi_demo.php?action=engine"> <input type="submit" value="エンジンを掛ける" /> </form> <form method="post" action="taxi_demo.php?action=run"> <input type="submit" value="走る" />
<?php include 'classes/car.php'; //using public properties $car1 = new Car(); // $car1 -> make = 'Toyota'; // echo $car1 -> make.'<br />'; // // $car1 -> make = 'Toyota'; // $car1 -> make = 'Honda'; // echo $car1 -> make.'<br />'; //using a public method $car1->start(); $car1->setMake('Chevy'); echo $car1->getMake() . '<br />'; //constructors // $car2 = new Car; $car2 = new Car('Honda', 'Accord', 'Red'); echo $car2->getColor() . '<br />'; $car3 = new Car('Honda', 'Civic', 'Blue'); echo $car3->getColor() . '<br />';