public function FeedsTamperCSVTestCase::testRewrite in Feeds Tamper 7
File
- tests/
feeds_tamper.test, line 312 - Tests for feeds_tamper.module.
Class
- FeedsTamperCSVTestCase
- Tests the special case that is FeedsCSVParser.
Code
public function testRewrite() {
$importer_name = $this
->randomName();
$importer_id = drupal_strtolower($importer_name);
// Set up an importer.
$this
->createImporterConfiguration($importer_name, $importer_id);
// Set and configure plugins and mappings.
$this
->setPlugin($importer_id, 'FeedsCSVParser');
// We have a space in the source cause that was a problem at one point.
$mappings = array(
0 => array(
'source' => 'a /T~!@#$%^&*()_+`<>;:itle✈',
'target' => 'title',
),
1 => array(
'source' => 'a Body.',
'target' => 'Temporary target 1',
),
2 => array(
'source' => 'Blank source 1',
'target' => 'body',
),
);
$this
->addMappings($importer_id, $mappings);
// Copy the field to the node's body field.
$this
->addTamperPlugin($importer_id, 'Blank source 1', 'rewrite', array(
'text' => '[a body.]',
));
$path = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds_tamper') . '/tests/feeds_tamper/';
$nid = $this
->createFeedNode($importer_id, $path . 'csv_test.csv', 'Testing CSV Parser');
$this
->assertText('Basic page Testing CSV Parser has been created.');
$this
->assertText('Created 2 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.');
}