public function FeedsTamperCSVTestCase::test in Feeds Tamper 6
Same name and namespace in other branches
- 7 tests/feeds_tamper.test \FeedsTamperCSVTestCase::test()
File
- tests/
feeds_tamper.test, line 199 - Tests for feeds_tamper.module.
Class
- FeedsTamperCSVTestCase
- Tests the special case that is FeedsCSVParser.
Code
public function test() {
$importer = $this
->randomName();
$importer_name = $this
->randomString();
// Set up an importer.
$this
->createImporterConfiguration($importer_name, $importer);
// Set and configure plugins and mappings.
$this
->setPlugin($importer, 'FeedsCSVParser');
// We have a space in the source cause that was a problem at one point.
$mappings = array(
'0' => array(
'source' => 'a Title',
'target' => 'title',
),
'1' => array(
'source' => 'a Body',
'target' => 'body',
),
'2' => array(
'source' => 'a GUID',
'target' => 'guid',
'unique' => TRUE,
),
);
$this
->addMappings($importer, $mappings);
// Set update existing.
$this
->setSettings($importer, 'FeedsNodeProcessor', array(
'update_existing' => 1,
));
// Test basic plugin adding.
$settings = array(
'mode' => 0,
);
$id = $this
->addTamperPlugin($importer, 'a Title', 'convert_case', $settings);
$id2 = $this
->addTamperPlugin($importer, 'a Body', 'convert_case', $settings);
$path = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds_tamper') . '/tests/feeds_tamper/';
$nid = $this
->createFeedNode($importer, $path . 'csv_test.csv', 'Testing CSV Parser');
$this
->assertText('Page Testing CSV Parser has been created.');
$this
->assertText('Created 2 Story nodes.');
$this
->drupalGet('node');
$this
->assertText('HELLO WORLD');
$this
->assertText('THIS IS A GREAT BODY.');
$this
->assertText('WORLD DOES NOT RESPOND');
$this
->assertText('THIS IS A SAD BODY.');
$this
->disableTamperPlugin($id);
$this
->disableTamperPlugin($id2);
$this
->drupalPost('node/' . $nid . '/import', array(), 'Import');
$this
->assertText('Updated 2 Story nodes.');
$this
->drupalGet('node');
$this
->assertText('Hello world');
$this
->assertText('This is a great body.');
$this
->assertText('World does not respond');
$this
->assertText('This is a sad body.');
}