class DMSFeedsMapperLocationTestCase in Location Feeds 7
Same name and namespace in other branches
- 6 tests/location_feeds.dms.test \DMSFeedsMapperLocationTestCase
Hierarchy
- class \FeedsMapperLocationTestCase extends \FeedsMapperTestCase
Expanded class hierarchy of DMSFeedsMapperLocationTestCase
File
- tests/
location_feeds.dms.test, line 13
View source
class DMSFeedsMapperLocationTestCase extends FeedsMapperLocationTestCase {
public static function getInfo() {
return array(
'name' => t('DMS Locations'),
'description' => t('Test Feeds Mapper support for DMS Locations.'),
'group' => t('Location Feeds'),
);
}
/**
* Set up the test.
*/
public function setUp() {
// Call parent setup with required modules.
parent::setUp(array(
'location',
'location_node',
'location_feeds',
));
// Create user and login.
$this
->drupalLogin($this
->drupalCreateUser(array(
'administer content types',
'administer feeds',
'administer nodes',
'administer site configuration',
'submit latitude/longitude',
)));
}
/**
* Basic test loading an RSS feed for nodes with locations.
*/
public function test() {
$settings = array();
$type = $this
->createLocationType($settings);
// Test constants
$loc = array(
0 => array(
'latitude' => 32.178333,
'longitude' => -115.276111,
),
1 => array(
'latitude' => 40.611111,
'longitude' => -124.763611,
),
2 => array(
// The White House.
'latitude' => '38.898648',
'longitude' => '-77.037692',
),
3 => array(
// The Vatican.
'latitude' => '41.910833',
'longitude' => '12.451944',
),
4 => array(
// Machu Picchu.
'latitude' => '-13.163056',
'longitude' => '-72.545556',
),
5 => array(
// Sydney Opera House.
'latitude' => '-33.858667',
'longitude' => '151.214028',
),
);
// Create and configure importer.
// Create a feed.
$this
->createImporterConfiguration('Location import', 'location_import');
// Set and configure plugins.
$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,
));
// Go to mapping page and create a couple of mappings.
$mappings = array(
array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
array(
'source' => 'guid',
'target' => 'guid',
'unique' => TRUE,
),
array(
'source' => 'lat',
'target' => 'locations:locpick][user_latitude',
'unique' => FALSE,
),
array(
'source' => 'long',
'target' => 'locations:locpick][user_longitude',
'unique' => FALSE,
),
);
$this
->addMappings('location_import', $mappings);
// Import CSV file.
$this
->importFile('location_import', drupal_get_path('module', 'location_feeds') . '/tests/feeds/location_dms.csv');
$this
->assertText('Created 6 nodes');
// Check the imported locations
$x = 0;
$nodes = db_query("SELECT nid FROM {node} WHERE type=:type", array(
':type' => $type,
));
foreach ($nodes as $node) {
$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++;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DMSFeedsMapperLocationTestCase:: |
public static | function | ||
DMSFeedsMapperLocationTestCase:: |
public | function | Set up the test. | |
DMSFeedsMapperLocationTestCase:: |
public | function | Basic test loading an RSS feed for nodes with locations. | |
FeedsMapperLocationTestCase:: |
public | function | ||
FeedsMapperLocationTestCase:: |
public | function |