/**
  * 
  * @depends testFindPotentialRides
  * @depends testFindRidesToNotify
  */
 function testSearchForMatchingRides()
 {
     TestUtils::clearDatabase();
     $ride1 = TestUtils::createSimpleRide(1, 2, STATUS_LOOKING);
     $ride2 = TestUtils::createSimpleRide(1, 3, STATUS_LOOKING);
     $ride3 = TestUtils::createSimpleRide(1, 2, STATUS_OFFERED);
     $ride4 = TestUtils::createSimpleRide(3, 4, STATUS_OFFERED);
     $ride5 = TestUtils::createSimpleRide(1, 7, STATUS_OFFERED);
     $toNotify = Service_ShowInterest::findRidesToNotify(STATUS_LOOKING, 1);
     $potentials = Service_ShowInterest::findPotentialRides(STATUS_LOOKING, 1);
     $matching = Service_ShowInterest::searchForMatchingRides($potentials, $toNotify);
     $expectedResults = array($ride1 => array($ride3));
     $this->assertMatchingResults($matching, $expectedResults, "TestSearchForMatchingRides: Test 1");
     // Now, see what happens with don't-cares
     $ride6 = TestUtils::createSimpleRide(1, LOCATION_DONT_CARE, STATUS_LOOKING);
     $ride7 = TestUtils::createSimpleRide(LOCATION_DONT_CARE, 7, STATUS_LOOKING);
     // One for the sharing
     $ride8 = TestUtils::createSimpleRide(1, 2, STATUS_SHARING);
     $toNotify = Service_ShowInterest::findRidesToNotify(STATUS_LOOKING, 1);
     $potentials = Service_ShowInterest::findPotentialRides(STATUS_LOOKING, 1);
     $matching = Service_ShowInterest::searchForMatchingRides($potentials, $toNotify);
     // We should now have 3 results:
     //   ride1: ride3, ride8
     //   ride6: ride3, ride5, ride8
     //   ride7: ride5
     $expectedResults = array($ride1 => array($ride3, $ride8), $ride6 => array($ride3, $ride5, $ride8), $ride7 => array($ride5));
     $this->assertMatchingResults($matching, $expectedResults, "TestSearchForMatchingRides: Test 2");
     // Now test the other way
     $toNotify = Service_ShowInterest::findRidesToNotify(STATUS_OFFERED, 1);
     $potentials = Service_ShowInterest::findPotentialRides(STATUS_OFFERED, 1);
     $matching = Service_ShowInterest::searchForMatchingRides($potentials, $toNotify);
     // We should now have (wildcards in the rides to notify are not supported yet):
     //   ride3: ride1
     // TODO: Implement support for wildcards on the other way as well
     $expectedResults = array($ride3 => array($ride1, $ride8));
     $this->assertMatchingResults($matching, $expectedResults, "TestSearchForMatchingRides: Test 3");
     // And what happens when they share
     $toNotify = Service_ShowInterest::findRidesToNotify(STATUS_SHARING, 1);
     $potentials = Service_ShowInterest::findPotentialRides(STATUS_SHARING, 1);
     $matching = Service_ShowInterest::searchForMatchingRides($potentials, $toNotify);
     // We should now have the following results:
     //   ride8: ride1, ride3
     $expectedResults = array($ride8 => array($ride3, $ride1));
     $this->assertMatchingResults($matching, $expectedResults, "TestSearchForMatchingRides: Test 4");
 }