/** * Test getting the best lap and the number of laps */ public function testBestLapAndNumberOfLaps() { // Get populated participant $participant = $this->getParticipantWithLaps(); // Get best lap $best_lap = $participant->getBestLap(); // Test lap time $this->assertSame(125.73, $best_lap->getTime()); // Test number of laps $this->assertSame(6, $participant->getNumberOfLaps()); //-- Run twice to test cache for ($i = 0; $i < 2; $i++) { // Test number of completed laps $this->assertSame(5, $participant->getNumberOfCompletedLaps()); } //-- Create participant with 2 uncompleted laps and test NULL best lap $participant = new Participant(); $participant->setLaps(array(new Lap(), new Lap())); // No best lap $this->assertNull($participant->getBestLap()); }