public function FeedsMapperPathTestCase::testTermAlias in Feeds 7.2
Test support for term aliases.
File
- tests/
feeds_mapper_path.test, line 88 - Contains FeedsMapperPathTestCase.
Class
- FeedsMapperPathTestCase
- Test case for path alias mapper path.inc.
Code
public function testTermAlias() {
// Create importer configuration.
$this
->createImporterConfiguration($this
->randomName(), 'path_test');
$this
->setPlugin('path_test', 'FeedsFileFetcher');
$this
->setPlugin('path_test', 'FeedsCSVParser');
$this
->setPlugin('path_test', 'FeedsTermProcessor');
// Create vocabulary.
$edit = array(
'name' => 'Addams vocabulary',
'machine_name' => 'addams',
);
$this
->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
$this
->setSettings('path_test', 'FeedsTermProcessor', array(
'bundle' => 'addams',
'update_existing' => 2,
));
// Add mappings.
$this
->addMappings('path_test', array(
0 => array(
'source' => 'Title',
'target' => 'name',
),
1 => array(
'source' => 'path',
'target' => 'path_alias',
),
2 => array(
'source' => 'GUID',
'target' => 'guid',
'unique' => TRUE,
),
));
// Import RSS file.
$this
->importFile('path_test', $this
->absolutePath() . '/tests/feeds/path_alias.csv');
$this
->assertText('Created 9 terms');
$aliases = array();
for ($i = 1; $i <= 9; $i++) {
$aliases[] = "path{$i}";
}
$this
->assertAliasCount($aliases);
// Adding a mapping will force update.
$this
->addMappings('path_test', array(
3 => array(
'source' => 'fake',
'target' => 'description',
),
));
// Import RSS file.
$this
->importFile('path_test', $this
->absolutePath() . '/tests/feeds/path_alias.csv');
$this
->assertText('Updated 9 terms');
// Check that duplicate aliases are not created.
$this
->assertAliasCount($aliases);
}