public function XPathXMLParserTest::testVariables in Feeds XPath Parser 8
Test variable substitution.
File
- lib/
Drupal/ feeds_xpathparser/ Tests/ XPathXMLParserTest.php, line 198 - Contains Drupal\feeds_xpathparser\Tests\XPathXMLParserTest.
Class
- XPathXMLParserTest
- Test single feeds.
Namespace
Drupal\feeds_xpathparser\TestsCode
public function testVariables() {
$this
->createImporterConfiguration();
$this
->setPlugin('syndication', 'parser', 'feeds_xpathparser_xml');
$importer_url = self::FEEDS_BASE . '/syndication/settings/parser';
$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(
'context' => '//entry',
'sources[xpathparser:0]' => 'title',
'sources[xpathparser:1]' => 'id',
'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/';
// We use an atom feed so that we can test that default namespaces are being
// applied appropriately.
$fid = $this
->createFeed('syndication', $path . 'rewrite_test.xml', 'Testing XPath XML Parser');
$feed_edit_url = 'feed/' . $fid . '/edit';
$this
->assertText('Created 3 nodes');
$this
->drupalGet('node');
}