public function FeedsEntityProcessorDateTest::testTimezoneMappingOption in Feeds entity processor 7
Tests importing dates using the timezone mapping option.
File
- tests/
src/ FeedsEntityProcessorDateTest.test, line 109 - Contains FeedsEntityProcessorDateTest.
Class
- FeedsEntityProcessorDateTest
- Tests importing entities with properties of various data types.
Code
public function testTimezoneMappingOption() {
// Los Angeles == UTC-08:00.
$this
->addMappings('syndication', array(
2 => array(
'source' => 'created',
'target' => 'created',
'timezone' => 'America/Los_Angeles',
),
));
// Run import.
$this
->importURL('syndication', $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds_entity_processor') . '/tests/resources/content_date.csv');
$this
->assertText('Created 7 test entities');
$expected_values = $this
->getExpectedTimestamps();
// Increase each timestamp with 8 hours (28800 seconds), except for:
// - date 1, which is a timestamp by itself;
// - date 2, 3 and 7, which are summertime dates;
// - date 4, which has a timezone of its own.
foreach ($expected_values as $key => &$value) {
switch ($key) {
case 1:
case 4:
break;
case 2:
case 3:
case 7:
// Summertime: UTC-07:00.
$value += 25200;
break;
default:
// Winter time: UTC-08:00.
$value += 28800;
}
}
foreach ($expected_values as $entity_id => $expected_value) {
$entity = entity_load_single('feeds_entity_processor_test', $entity_id);
$this
->assertEqual($expected_value, $entity->created);
}
}