protected function ParserCSVTest::_testBatching in Feeds 7
Same name and namespace in other branches
- 6 tests/parser_csv.test \ParserCSVTest::_testBatching()
- 7.2 tests/parser_csv.test \ParserCSVTest::_testBatching()
Test batching.
1 call to ParserCSVTest::_testBatching()
- ParserCSVTest::test in tests/
parser_csv.test - Test method.
File
- tests/
parser_csv.test, line 56 - Tests for ParserCSV library.
Class
- ParserCSVTest
- Test aggregating a feed as node items.
Code
protected function _testBatching() {
$file = $this
->absolutePath() . '/tests/feeds/nodes.csv';
include $this
->absolutePath() . '/tests/feeds/nodes.csv.php';
// Set up parser with 2 lines to parse per call.
$iterator = new ParserCSVIterator($file);
$parser = new ParserCSV();
$parser
->setDelimiter(',');
$parser
->setLineLimit(2);
$rows = array();
$pos = 0;
// Call parser until all lines are parsed, then compare to control result.
do {
$parser
->setStartByte($pos);
$rows = array_merge($rows, $parser
->parse($iterator));
$pos = $parser
->lastLinePos();
$this
->assertTrue($parser
->lastLinePos() || count($rows) == 10, t('Parser reports line limit correctly'));
} while ($pos = $parser
->lastLinePos());
$this
->assertEqual(md5(serialize($rows)), md5(serialize($control_result)), t('Parsed result matches control result.'));
}