public function CsvParserTest::testFeedWithExtraBlankLines in Feeds 8.3
Tests parsing a file with a few extra blank lines.
File
- tests/
src/ Unit/ Feeds/ Parser/ CsvParserTest.php, line 160
Class
- CsvParserTest
- @coversDefaultClass \Drupal\feeds\Feeds\Parser\CsvParser @group feeds
Namespace
Drupal\Tests\feeds\Unit\Feeds\ParserCode
public function testFeedWithExtraBlankLines() {
$this->feedType
->method('getMappingSources')
->will($this
->returnValue([]));
// Set an high line limit.
$configuration = [
'feed_type' => $this->feedType,
'line_limit' => 100,
];
$this->parser = new CsvParser($configuration, 'csv', []);
$this->parser
->setStringTranslation($this
->getStringTranslationStub());
$this->feed
->expects($this
->any())
->method('getConfigurationFor')
->with($this->parser)
->will($this
->returnValue($this->parser
->defaultFeedConfiguration()));
$file = $this
->resourcesPath() . '/csv/with-empty-lines.csv';
$fetcher_result = new FetcherResult($file);
$result = $this->parser
->parse($this->feed, $fetcher_result, $this->state);
$this
->assertCount(9, $result);
// Parse again.
$result = $this->parser
->parse($this->feed, $fetcher_result, $this->state);
$this
->assertCount(0, $result);
// Assert that parsing has finished.
$this
->assertEquals(StateInterface::BATCH_COMPLETE, $this->state->progress);
}