You are here

public function QueryPathHtmlParserTest::testRaw in Feeds extensible parsers 8

Tests raw.

File

tests/src/Unit/Feeds/Parser/QueryPathHtmlParserTest.php, line 69

Class

QueryPathHtmlParserTest
@coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\QueryPathHtmlParser @group feeds_ex

Namespace

Drupal\Tests\feeds_ex\Unit\Feeds\Parser

Code

public function testRaw() {
  $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' => '',
        'raw' => TRUE,
      ],
    ],
  ];
  $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('<p>I am a description0</p>', $result[0]
    ->get('description'));
  $this
    ->assertSame('I am a title1', $result[1]
    ->get('title'));
  $this
    ->assertSame('<p>I am a description1</p>', $result[1]
    ->get('description'));
  $this
    ->assertSame('I am a title2', $result[2]
    ->get('title'));
  $this
    ->assertSame('<p>I am a description2</p>', $result[2]
    ->get('description'));
}