View source
<?php
module_load_include('inc', 'location_feeds', 'tests/location_feeds.test');
class GeoRSSFeedsMapperLocationTestCase extends FeedsMapperLocationTestCase {
public static function getInfo() {
return array(
'name' => t('GeoRSS Locations'),
'description' => t('Test Feeds Mapper support for GeoRSS Locations.'),
'group' => t('Location Feeds'),
);
}
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler', 'location', 'location_node', 'location_feeds', 'content');
$this
->drupalLogin($this
->drupalCreateUser(array(
'administer content types',
'administer feeds',
'administer nodes',
'administer site configuration',
'submit latitude/longitude',
)));
}
public function test() {
$settings = array();
$type = $this
->createLocationType($settings);
$loc = array(
0 => array(
'latitude' => 32.1783,
'longitude' => -115.2768,
),
1 => array(
'latitude' => 40.6083,
'longitude' => -124.7635,
),
);
$this
->createImporterConfiguration('Location import', 'location_import');
$this
->setSettings('location_import', NULL, array(
'content_type' => '',
'import_period' => FEEDS_SCHEDULE_NEVER,
));
$this
->setPlugin('location_import', 'FeedsFileFetcher');
$this
->setPlugin('location_import', 'FeedsCSVParser');
$this
->setSettings('location_import', 'FeedsNodeProcessor', array(
'content_type' => $type,
));
$mappings = array(
array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
array(
'source' => 'guid',
'target' => 'guid',
'unique' => TRUE,
),
array(
'source' => 'georss:point',
'target' => 'locations:georss:point',
'unique' => FALSE,
),
);
$this
->addMappings('location_import', $mappings);
$this
->importFile('location_import', drupal_get_path('module', 'location_feeds') . '/tests/feeds/location_georss.csv');
$this
->assertText('Created 2 ' . $type . ' nodes.');
$x = 0;
$res = db_query("SELECT nid FROM {node} WHERE type='%s'", $type);
while ($node = db_fetch_object($res)) {
$node = node_load($node->nid);
$this
->assertEqual($loc[$x]['latitude'], $node->locations[0]['latitude'], t('Testing latitude import, expected: @e, found: @f', array(
'@e' => $loc[$x]['latitude'],
'@f' => $node->locations[0]['latitude'],
)));
$this
->assertEqual($loc[$x]['longitude'], $node->locations[0]['longitude'], t('Testing longitude import, expected: @e, found: @f', array(
'@e' => $loc[$x]['longitude'],
'@f' => $node->locations[0]['longitude'],
)));
$x++;
}
}
}