You are here

public function FeedsExXmlUnitTests::testBatching in Feeds extensible parsers 7.2

Tests batching.

File

src/Tests/FeedsExXml.test, line 141
Contains tests for FeedsExXml.

Class

FeedsExXmlUnitTests
Unit tests for FeedsExXml.

Code

public function testBatching() {
  $parser = FeedsConfigurable::instance('FeedsExXml', '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',
      ),
      'description' => array(
        'name' => 'Title',
        'value' => 'description',
      ),
    ),
  ));
  $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']);
  }
}