public function QueryPathHtmlParserTest::testSimpleParsing in Feeds extensible parsers 8
Tests simple parsing.
File
- tests/
src/ Unit/ Feeds/ Parser/ QueryPathHtmlParserTest.php, line 33
Class
- QueryPathHtmlParserTest
- @coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\QueryPathHtmlParser @group feeds_ex
Namespace
Drupal\Tests\feeds_ex\Unit\Feeds\ParserCode
public function testSimpleParsing() {
$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' => '',
],
'description' => [
'name' => 'Title',
'value' => 'p',
'attribute' => '',
],
],
];
$this->parser
->setConfiguration($config);
$result = $this->parser
->parse($this->feed, $fetcher_result, $this->state);
$this
->assertCount(3, $result);
$this
->assertSame('I am a title<thing>Stuff</thing>', $result[0]
->get('title'));
$this
->assertSame('I am a description0', $result[0]
->get('description'));
$this
->assertSame('I am a title1', $result[1]
->get('title'));
$this
->assertSame('I am a description1', $result[1]
->get('description'));
$this
->assertSame('I am a title2', $result[2]
->get('title'));
$this
->assertSame('I am a description2', $result[2]
->get('description'));
}