/** * Test friendly vehicle name */ public function testFriendlyVehicleName() { // Init new Vehicle $vehicle = new Vehicle(); // Set names $vehicle->setName('Lola T280 JL Lafosse'); $vehicle->setType('LolaT280 ('); // Set ( char to test for regex errors $vehicle->setClass('LolaT280'); // Validate friendly name $this->assertSame('Lola T280 JL Lafosse - LolaT280 (', $vehicle->getFriendlyName()); // Change class name $vehicle->setClass('LolaT280B'); // Validate friendly name $this->assertSame('Lola T280 JL Lafosse - LolaT280 ( (LolaT280B)', $vehicle->getFriendlyName()); }
/** * Get a Session instance populated with test data. * * NOTE: Every time this method is ran, a different instance will be * returned! Keep this in mind when comparing things by reference * * @return Session */ protected function getSessionWithData() { // Create new session $session = new Session(); // Participants testdata array $participants_data = array(array('position' => 1, 'vehicle' => array('class' => 'class1'), 'laps' => array(array('time' => 130.7517, 'sectors' => array(53.2312, 32.299, 45.2215), 'position' => 1), array('time' => 125.2989, 'sectors' => array(47.4511, 32.063, 45.7848), 'position' => 1), array('time' => 123.3179, 'sectors' => array(46.6382, 32.0084, 44.6712), 'position' => 1))), array('position' => 2, 'vehicle' => array('class' => 'class3'), 'laps' => array(array('time' => 130.9077, 'sectors' => array(54.0223, 32.3176, 44.5677), 'position' => 2), array('time' => 125.6976, 'sectors' => array(47.5271, 32.4621, 45.7083), 'position' => 2), array('time' => 126.062, 'sectors' => array(47.7989, 32.7721, 45.491), 'position' => 2))), array('position' => 3, 'vehicle' => array('class' => 'class2'), 'laps' => array(array('time' => 134.8484, 'sectors' => array(56.0119, 32.4913, 46.3452), 'position' => 12), array('time' => 126.2454, 'sectors' => array(50.4389, 31.8827, 43.9237), 'position' => 3), array('time' => 122.0663, 'sectors' => array(46.2715, 31.8696, 43.9252), 'position' => 3))), array('position' => 4, 'vehicle' => array('class' => 'class1'), 'laps' => array(array('time' => 155.1491, 'sectors' => array(60.0119, 40.4913, 54.6459), 'position' => 4), array('time' => 156.1491, 'sectors' => array(60.0119, 40.4913, 55.6459), 'position' => 4))), array('position' => 5, 'vehicle' => array('class' => 'class2'), 'laps' => array()), array('position' => 6, 'vehicle' => array('class' => 'class3'), 'laps' => array(array('time' => null, 'sectors' => array(42.4389), 'position' => 6)))); // Loop each participant data foreach ($participants_data as $participant_data) { // Create the new participant and populate $participant = new Participant(); $participant->setPosition($participant_data['position']); $vehicle = new Vehicle(); $vehicle->setClass($participant_data['vehicle']['class']); $participant->setVehicle($vehicle); // Create each lap foreach ($participant_data['laps'] as $lap_key => $lap_data) { $lap = new Lap(); $lap->setTime($lap_data['time'])->setSectorTimes($lap_data['sectors'])->setNumber($lap_key + 1)->setPosition($lap_data['position'])->setParticipant($participant); // Add lap to participant $participant->addLap($lap); } // Add participant to session $session->addParticipant($participant); } // Return the session return $session; }