/** * Test the best lap */ public function testBestLap() { // Get session $session = $this->getSessionWithData(); // Get the best lap $lap = $session->getBestLap(); // Get participants $participants = $session->getParticipants(); // Validate best lap $this->assertSame($participants[2]->getBestLap(), $lap); //-- Create participant with 2 uncompleted laps and test NULL best lap // from the session $participant = new Participant(); $participant->setLaps(array(new Lap(), new Lap())); $session = new Session(); $session->setParticipants(array($participant)); // No best lap $this->assertNull($session->getBestLap()); }
/** * 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()); }