public function testPopulateTransactionData()
 {
     $transaction = new Application_Model_Transaction();
     $file_handle = fopen(APPLICATION_PATH . '/data/EXAMPLE.csv', "r");
     $field_names = fgetcsv($file_handle);
     //header row
     $entry = fgetcsv($file_handle);
     //first row
     fclose($file_handle);
     $feed_data = array_combine($field_names, $entry);
     $feed_data['depository'] = 'DTCC';
     $transaction->populateFromDescriptionData($feed_data);
     $this->assertSame($transaction->getAction(), 'NEW', 'transaction not set correctly');
     $trade_data = $transaction->getTradeData();
     $this->assertSame($trade_data['trade_id'], 1311449, 'trade data not set correctly');
     $this->assertSame($trade_data['inst_type'], 'IRSwap', 'categories not parsed correctly');
     $this->assertSame($trade_data['not_amount_1'], 250.0, 'size not calculated correctly');
     $this->assertSame($trade_data['term'], 10.0, 'term not calculated correctly');
 }
 /**
  * processes each of the RSS feed entries and converts them
  * to transaction objects
  * 
  * @param array $entries
  * @return multitype:Application_Model_Transaction
  * 
  * @access protected
  */
 protected function _processFeedData($entries)
 {
     if (count($entries)) {
         $options = $this->_getConfigOptions();
         $header_file = $options['data']['dir'] . $options['data']['header'];
         //read the data fields from file provided by DTCC  http:/dtcc.com
         $header = fopen($header_file, 'r');
         $field_names = fgetcsv($header);
         fclose($header);
     }
     //process the "description" field from each rss "item"
     $transactions = array();
     foreach ($entries as $entry) {
         // 'description' field is a CSV string so parse it
         $parsed_data = str_getcsv($entry['description']);
         if (count($field_names) === count($parsed_data)) {
             $feed_data = array_combine($field_names, $parsed_data);
             //set the depository name here
             $feed_data['depository'] = 'DTCC';
             $transaction = new Application_Model_Transaction();
             $transaction->populateFromDescriptionData($feed_data);
             $transactions[] = $transaction;
         } else {
             Zend_Registry::get('logger')->log('Feed data length does not match. Specification may have changed', Zend_Log::WARN);
         }
     }
     return $transactions;
 }