public function FeedsEntityProcessorBasicTest::testEntityIdAsUniqueTarget in Feeds entity processor 7
Tests if the entity ID can be used as an unique target.
File
- tests/
src/ FeedsEntityProcessorBasicTest.test, line 96 - Tests for plugins/FeedsEntityProcessor.inc.
Class
- FeedsEntityProcessorBasicTest
- Tests importing entities using the generic processor.
Code
public function testEntityIdAsUniqueTarget() {
// Include FeedsProcessor.inc so processor related constants are available.
module_load_include('inc', 'feeds', 'plugins/FeedsProcessor');
$bundle = drupal_strtolower($this
->randomName());
// Create bundle entity.
entity_create('entity_test_type', array(
'id' => drupal_strtolower($this
->randomName()),
'name' => $bundle,
))
->save();
// Create an entity_test record in the database.
$record = array(
'pid' => 1,
'name' => $bundle,
'uid' => 0,
);
drupal_write_record('entity_test', $record);
// Set importer settings.
$this
->setPlugin('syndication', 'FeedsCSVParser');
$this
->setSettings('syndication', 'FeedsEntityProcessorEntity_test', array(
'bundle' => $bundle,
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Map to entity ID.
$this
->addMappings('syndication', array(
0 => array(
'source' => 'guid',
'target' => 'pid',
'unique' => TRUE,
),
));
// Run import.
$this
->importURL('syndication', $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv');
$this
->assertText('Updated 1 test entity');
$this
->assertText('Created 1 test entity');
}