You are here

public function FeedsExQueryPathXmlUnitTests::testBatchParsing in Feeds extensible parsers 7.2

Tests that batch parsing works.

File

src/Tests/FeedsExQueryPathXml.test, line 187
Contains tests for FeedsExQueryPathXml.

Class

FeedsExQueryPathXmlUnitTests
Unit tests for FeedsExQueryPathXml.

Code

public function testBatchParsing() {
  $parser = FeedsConfigurable::instance('FeedsExQueryPathXml', 'test_parser');
  $fetcher_result = new FeedsFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test.xml'));
  $parser
    ->setConfig(array(
    'context' => array(
      'value' => 'items item',
    ),
    'sources' => array(
      'title' => array(
        'name' => 'Title',
        'value' => 'title',
        'attribute' => '',
      ),
      'description' => array(
        'name' => 'Title',
        'value' => 'description',
        'attribute' => '',
      ),
    ),
  ));

  // Yay TUnit!
  $this
    ->variableSet('feeds_process_limit', 1);
  foreach (range(0, 2) as $delta) {
    $result = $parser
      ->parse($this->source, $fetcher_result);
    $this
      ->assertEqual(count($result->items), 1, format_string('@count items parsed.', array(
      '@count' => count($result->items),
    )));
    $this
      ->assertEqual('I am a title' . $delta, $result->items[0]['title']);
    $this
      ->assertEqual('I am a description' . $delta, $result->items[0]['description']);
  }
}