public function QueryPathHtmlParserTest::testAttributeParsing in Feeds extensible parsers 8
Tests grabbing an attribute.
File
- tests/
src/ Unit/ Feeds/ Parser/ QueryPathHtmlParserTest.php, line 144
Class
- QueryPathHtmlParserTest
- @coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\QueryPathHtmlParser @group feeds_ex
Namespace
Drupal\Tests\feeds_ex\Unit\Feeds\ParserCode
public function testAttributeParsing() {
$fetcher_result = new RawFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test.html'), $this->fileSystem);
$config = [
'context' => [
'value' => '.post',
],
'sources' => [
'title' => [
'name' => 'Title',
'value' => 'h3',
'attribute' => 'attr',
],
'description' => [
'name' => 'Title',
'value' => 'p',
'attribute' => '',
],
],
];
$this->parser
->setConfiguration($config);
$result = $this->parser
->parse($this->feed, $fetcher_result, $this->state);
$this
->assertCount(3, $result);
foreach ($result as $delta => $item) {
$this
->assertSame('attribute' . $delta, $item
->get('title'));
$this
->assertSame('I am a description' . $delta, $item
->get('description'));
}
}