You are here

public function FeedsXPathParserXMLTestCase::testVariables in Feeds XPath Parser 6

Same name and namespace in other branches
  1. 7 tests/feeds_xpathparser_parser_xml.test \FeedsXPathParserXMLTestCase::testVariables()

Test variable substitution.

File

tests/feeds_xpathparser_parser_xml.test, line 198

Class

FeedsXPathParserXMLTestCase
Test single feeds.

Code

public function testVariables() {
  $this
    ->createImporterConfiguration();
  $this
    ->setPlugin('syndication', 'FeedsXPathParserXML');
  $importer_url = $this->feeds_base . '/syndication/settings/FeedsXPathParserXML';
  $this
    ->addMappings('syndication', array(
    array(
      'source' => 'xpathparser:0',
      'target' => 'title',
      'unique' => FALSE,
    ),
    array(
      'source' => 'xpathparser:1',
      'target' => 'guid',
      'unique' => TRUE,
    ),
    array(
      'source' => 'xpathparser:2',
      'target' => 'body',
      'unique' => FALSE,
    ),
  ));

  // Set importer default settings.
  $edit = array(
    'xpath[context]' => '//entry',
    'xpath[sources][xpathparser:0]' => 'title',
    'xpath[sources][xpathparser:1]' => 'id',
    'xpath[sources][xpathparser:2]' => 'link/@$title',
  );
  $this
    ->postAndCheck($importer_url, $edit, 'Save', 'Your changes have been saved.');

  // Test import.
  $path = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds_xpathparser') . '/tests/feeds_xpathparser/';

  // We use an atom feed so that we can test that default namespaces are being
  // applied appropriately.
  $nid = $this
    ->createFeedNode('syndication', $path . 'rewrite_test.xml', 'Testing XPath XML Parser');
  $feed_node_edit_url = 'node/' . $nid . '/edit';
  $this
    ->assertText('Created 3 Story nodes.');
  $this
    ->drupalGet('node');
}