You are here

public function QueryPathXmlParserTest::testRaw in Feeds extensible parsers 8

Tests raw parsing.

File

tests/src/Unit/Feeds/Parser/QueryPathXmlParserTest.php, line 67

Class

QueryPathXmlParserTest
@coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\QueryPathXmlParser @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.xml'), $this->fileSystem);
  $config = [
    'context' => [
      'value' => 'items item',
    ],
    'sources' => [
      'title' => [
        'name' => 'Title',
        'value' => 'title',
        'attribute' => '',
      ],
      'description' => [
        'name' => 'Title',
        'value' => 'description',
        'attribute' => '',
        'raw' => TRUE,
      ],
    ],
  ];
  $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('I am a title' . $delta, $item
      ->get('title'));
    $this
      ->assertXmlStringEqualsXmlString('<description><text>I am a description' . $delta . '</text></description>', $item
      ->get('description'));
  }
}