You are here

public function FeedsMapperFieldTestCase::getCurrentMappings in Entity reference 7

Gets an array of current mappings from the feeds_importer config.

Parameters

string $id: ID of the importer.

Return value

bool|array FALSE if the importer has no mappings, or an an array of mappings.

1 call to FeedsMapperFieldTestCase::getCurrentMappings()
FeedsMapperFieldTestCase::mappingExists in tests/entityreference.feeds.test
Check if mapping exists.

File

tests/entityreference.feeds.test, line 137
Test case for simple CCK field mapper mappers/content.inc.

Class

FeedsMapperFieldTestCase
Class for testing Feeds field mapper.

Code

public function getCurrentMappings($id) {
  $config = db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(
    ':id' => $id,
  ))
    ->fetchField();
  $config = unserialize($config);

  // We are very specific here. 'mappings' can either be an array or not
  // exist.
  if (array_key_exists('mappings', $config['processor']['config'])) {
    $this
      ->assertTrue(is_array($config['processor']['config']['mappings']), 'Mappings is an array.');
    return $config['processor']['config']['mappings'];
  }
  return FALSE;
}