public function XmlParserTest::testBatching in Feeds extensible parsers 8
Tests batching.
File
- tests/
src/ Unit/ Feeds/ Parser/ XmlParserTest.php, line 204
Class
- XmlParserTest
- @coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\XmlParser @group feeds_ex
Namespace
Drupal\Tests\feeds_ex\Unit\Feeds\ParserCode
public function testBatching() {
$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',
],
'description' => [
'name' => 'Title',
'value' => 'description',
],
],
'line_limit' => 1,
] + $this->parser
->defaultConfiguration();
$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'));
}
// Should be empty.
$result = $this->parser
->parse($this->feed, $fetcher_result, $this->state);
$this
->assertCount(0, $result);
}