You are here

public function FeedsXPathParserXMLTestCase::testVariables in Feeds XPath Parser 7

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

Test variable substitution.

File

tests/feeds_xpathparser_parser_xml.test, line 196
Tests for FeedsXPathParserXML.inc.

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(
    0 => array(
      'source' => 'xpathparser:0',
      'target' => 'title',
      'unique' => FALSE,
    ),
    1 => array(
      'source' => 'xpathparser:1',
      'target' => 'guid',
      'unique' => TRUE,
    ),
    2 => array(
      'source' => 'xpathparser:2',
      'target' => 'body',
    ),
  ));

  // 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 nodes');
  $this
    ->drupalGet('node');
}