public function FeedsExQueryPathHtmlUnitTests::testAttributeParsing in Feeds extensible parsers 7.2
Tests grabbing an attribute.
File
- src/
Tests/ FeedsExQueryPathHtml.test, line 82 - Contains tests for FeedsExQueryPathHtml.
Class
- FeedsExQueryPathHtmlUnitTests
- Unit tests for FeedsExQueryPathHtml.
Code
public function testAttributeParsing() {
$parser = FeedsConfigurable::instance('FeedsExQueryPathHtml', 'test_parser');
$fetcher_result = new FeedsFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test.html'));
$parser
->setConfig(array(
'context' => array(
'value' => '.post',
),
'sources' => array(
'title' => array(
'name' => 'Title',
'value' => 'h3',
'attribute' => 'attr',
),
'description' => array(
'name' => 'Title',
'value' => 'p',
'attribute' => '',
),
),
));
$result = $parser
->parse($this->source, $fetcher_result);
$this
->assertEqual(count($result->items), 3, format_string('@count items parsed.', array(
'@count' => count($result->items),
)));
foreach ($result->items as $delta => $item) {
$this
->assertEqual('attribute' . $delta, $item['title']);
$this
->assertEqual('I am a description' . $delta, $item['description']);
}
}