You are here

public function QueryPathXmlParserTest::testBatchParsing in Feeds extensible parsers 8

Tests that batch parsing works.

File

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

Class

QueryPathXmlParserTest
@coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\QueryPathXmlParser @group feeds_ex

Namespace

Drupal\Tests\feeds_ex\Unit\Feeds\Parser

Code

public function testBatchParsing() {
  $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' => '',
      ],
    ],
    'line_limit' => 1,
  ];
  $this->parser
    ->setConfiguration($config);
  foreach (range(0, 2) as $delta) {
    $result = $this->parser
      ->parse($this->feed, $fetcher_result, $this->state);
    $this
      ->assertCount(1, $result);
    $this
      ->assertSame('I am a title' . $delta, $result[0]
      ->get('title'));
    $this
      ->assertSame('I am a description' . $delta, $result[0]
      ->get('description'));
  }
  $result = $this->parser
    ->parse($this->feed, $fetcher_result, $this->state);
  $this
    ->assertCount(0, $result);
}