/**
  * Saves a record of a new contribution to the contribution_tracking_table
  * @param array $params A staged array of parameters that can be processed
  * by the ContributionTrackingProcessor.
  * @return integer The id of the saved contribution in the
  * contribution_tracking table
  */
 static function saveNewContribution($params = array())
 {
     $db = ContributionTrackingProcessor::contributionTrackingConnection();
     $params['ts'] = $db->timestamp();
     $owa_ref = null;
     if (array_key_exists('owa_ref', $params) && $params['owa_ref'] != null) {
         if ($params['owa_ref'] == null || is_numeric($params['owa_ref'])) {
             $owa_ref = $params['owa_ref'];
         } else {
             $owa_ref = ContributionTrackingProcessor::get_owa_ref_id($params['owa_ref']);
         }
     }
     $params['owa_ref'] = $owa_ref;
     $tracked_contribution = ContributionTrackingProcessor::stage_contribution($params);
     $db->insert('contribution_tracking', $tracked_contribution);
     $contribution_tracking_id = $db->insertId();
     return $contribution_tracking_id;
 }
 /**
  * tests the get_owa_ref_id function
  * Assertions:
  * 		The unique add comes back with a numeric id.
  * 		The second call also comes back with a numeric id.
  * 		The insert and the lookup come back with the same numeric id.
  */
 function testGetOWARefID()
 {
     $testRef = "test_ref_" . time();
     $id_1 = ContributionTrackingProcessor::get_owa_ref_id($testRef);
     //add
     $id_2 = ContributionTrackingProcessor::get_owa_ref_id($testRef);
     //get
     $this->assertTrue(is_numeric($id_1), "First id is not numeric: Problem adding OWA Ref URL");
     $this->assertTrue(is_numeric($id_2), "Second id is not numeric: Problem retrieving OWA Ref ID");
     $this->assertEquals($id_1, $id_2, "IDs do not match.");
 }