Пример #1
0
 /**
  * Test getting the vehicles from the participant using the laps
  * collection too
  */
 public function testGettingVehicles()
 {
     // Init participant
     $participant = new Participant();
     // Init two vehicles
     $vehicle1 = new Vehicle();
     $vehicle2 = new Vehicle();
     // Init laps with the vehicles
     $lap1 = new Lap();
     $lap1->setVehicle($vehicle1);
     $lap2 = new Lap();
     $lap2->setVehicle($vehicle2);
     // Set laps to participant
     $participant->setLaps(array($lap1, $lap2));
     // Test getting vehicles
     $this->assertSame(array($vehicle1, $vehicle2), $participant->getVehicles());
     // Test getting one vehicle
     $this->assertSame($vehicle1, $participant->getVehicle());
     // Set new main vehicle on participant
     $participant->setVehicle($vehicle3 = new Vehicle());
     // Test getting the main set vehicle
     $this->assertSame($vehicle3, $participant->getVehicle());
     // Test that `getVehicle()` always returns the best lap vehicle
     $lap2->setTime(10);
     $this->assertSame($vehicle2, $participant->getVehicle());
 }