/** * * @param string $name * @param string $userId * @return Vehicle */ public function create($name, $userId) { $vehicle = new Vehicle(); $vehicle->setName($name); $vehicle->setUserId($userId); return $this->mapper->insert($vehicle); }
public function testUpdate() { $vehicle = Vehicle::fromRow(['id' => 123, 'name' => 'My Car']); $this->mapper->expects($this->once())->method('find')->with($this->equalTo(123))->will($this->returnValue($vehicle)); $updatedVehicle = Vehicle::fromRow(['id' => 123]); $updatedVehicle->setName('My Truck'); $this->mapper->expects($this->once())->method('update')->with($this->equalTo($updatedVehicle))->will($this->returnValue($updatedVehicle)); $result = $this->service->update(123, 'My Truck', $this->userId); $this->assertEquals($updatedVehicle, $result); }