public function FeedsTamperCSVTestCase::test in Feeds Tamper 7
Same name and namespace in other branches
- 6 tests/feeds_tamper.test \FeedsTamperCSVTestCase::test()
File
- tests/
feeds_tamper.test, line 248 - Tests for feeds_tamper.module.
Class
- FeedsTamperCSVTestCase
- Tests the special case that is FeedsCSVParser.
Code
public function test() {
$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' => 'body',
),
2 => array(
'source' => 'a GUID',
'target' => 'guid',
'unique' => TRUE,
),
3 => array(
'source' => 'Blank source 1',
'target' => 'uid',
),
);
$this
->addMappings($importer_id, $mappings);
// Set update existing.
$this
->setSettings($importer_id, 'FeedsNodeProcessor', array(
'update_existing' => 1,
));
// Test basic plugin adding.
$settings = array(
'mode' => 0,
);
$id = $this
->addTamperPlugin($importer_id, 'a /T~!@#$%^&*()_+`<>;:itle✈', 'convert_case', $settings);
$id2 = $this
->addTamperPlugin($importer_id, 'a Body.', 'convert_case', $settings);
// Verify that Blank source works for CSV parser.
$this
->addTamperPlugin($importer_id, 'Blank source 1', 'default_value', array(
'default_value' => $this->admin_user->uid,
));
$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.');
$this
->disableTamperPlugin($id);
$this
->disableTamperPlugin($id2);
$this
->drupalPost('node/' . $nid . '/import', array(), 'Import');
$this
->assertText('Updated 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.');
$this
->drupalGet('node/2/edit');
$this
->assertFieldByName('name', $this->admin_user->name);
}