Newer
Older
Alex Barth
committed
<?php
/**
* @file
* Test case for simple CCK field mapper mappers/content.inc.
*/
/**
* Class for testing Feeds field mapper.
Alex Barth
committed
*/
class FeedsMapperFieldTestCase extends FeedsMapperTestCase {
Alex Barth
committed
public static function getInfo() {
return array(
Dave Reid
committed
'name' => 'Mapper: Fields',
'description' => 'Test Feeds Mapper support for fields.',
'group' => 'Feeds',
Alex Barth
committed
);
}
Dave Reid
committed
public function setUp() {
parent::setUp(array('number'));
}
Alex Barth
committed
/**
* Basic test loading a double entry CSV file.
Alex Barth
committed
*/
function test() {
// Create content type.
$typename = $this->createContentType(array(), array(
Alex Barth
committed
'alpha' => 'text',
'beta' => 'number_integer',
'gamma' => 'number_decimal',
'delta' => 'number_float',
Alex Barth
committed
));
// Create and configure importer.
$this->createImporterConfiguration('Content CSV', 'csv');
Alex Barth
committed
$this->setSettings('csv', NULL, array('content_type' => '','import_period' => FEEDS_SCHEDULE_NEVER,));
$this->setPlugin('csv', 'FeedsFileFetcher');
$this->setPlugin('csv', 'FeedsCSVParser');
$this->setSettings('csv', 'FeedsNodeProcessor', array('content_type' => $typename));
$this->addMappings('csv', array(
array(
'source' => 'title',
'target' => 'title',
),
array(
'source' => 'created',
'target' => 'created',
),
array(
'source' => 'body',
'target' => 'body',
),
array(
'source' => 'alpha',
'target' => 'field_alpha',
),
array(
'source' => 'beta',
'target' => 'field_beta',
),
array(
'source' => 'gamma',
'target' => 'field_gamma',
),
array(
'source' => 'delta',
'target' => 'field_delta',
),
Alex Barth
committed
));
// Import CSV file.
$this->importFile('csv', $this->absolutePath() .'/tests/feeds/content.csv');
$this->assertText('Created 2 nodes');
Alex Barth
committed
// Check the two imported files.
$this->drupalGet('node/1/edit');
$this->assertNodeFieldValue('alpha', 'Lorem');
$this->assertNodeFieldValue('beta', '42');
$this->assertNodeFieldValue('gamma', '4.20');
$this->assertNodeFieldValue('delta', '3.14159');
Alex Barth
committed
$this->drupalGet('node/2/edit');
$this->assertNodeFieldValue('alpha', 'Ut wisi');
$this->assertNodeFieldValue('beta', '32');
$this->assertNodeFieldValue('gamma', '1.20');
$this->assertNodeFieldValue('delta', '5.62951');