function FeedsMapperTaxonomyTest::testInheritTaxonomy in Feeds 8.2
Tests inheriting taxonomy from the feed node.
File
- lib/
Drupal/ feeds/ Tests/ FeedsMapperTaxonomyTest.php, line 121 - Test case for taxonomy mapper mappers/taxonomy.inc.
Class
- FeedsMapperTaxonomyTest
- Class for testing Feeds <em>content</em> mapper.
Namespace
Drupal\feeds\TestsCode
function testInheritTaxonomy() {
// Adjust importer settings
$this
->setSettings('syndication', NULL, array(
'import_period' => FEEDS_SCHEDULE_NEVER,
));
$this
->setSettings('syndication', NULL, array(
'import_on_create' => FALSE,
));
$this
->assertText('Do not import on submission');
// Map feed node's taxonomy to feed item node's taxonomy.
$this
->addMappings('syndication', array(
5 => array(
'source' => 'parent:taxonomy:field_tags',
'target' => 'field_tags',
),
));
// Create feed node and add term term1.
$langcode = LANGUAGE_NOT_SPECIFIED;
$nid = $this
->createFeedNode('syndication', NULL, 'Syndication');
$term = taxonomy_term_load_multiple_by_name('term1');
$term = reset($term);
$node = node_load($nid)
->getNGEntity();
$node->field_tags = $term
->id();
$node
->save();
// Import nodes.
$this
->drupalPost("node/{$nid}/import", array(), 'Import');
$this
->assertText('Created 10 nodes.');
$count = db_query("SELECT COUNT(*) FROM {taxonomy_index}")
->fetchField();
// There should be one term for each node imported plus the term on the feed node.
$this
->assertEqual(11, $count, 'Found correct number of tags for all feed nodes and feed items.');
}