function it_flushes_a_buffer_into_multiple_files_with_extension($columnSorter, FlatItemBuffer $buffer)
 {
     $columnSorter->sort(Argument::any())->willReturn(['colA', 'colB']);
     $buffer->rewind()->willReturn();
     $buffer->count()->willReturn(3);
     $buffer->valid()->willReturn(true, true, true, false);
     $buffer->next()->willReturn();
     $buffer->current()->willReturn(['colA' => 'fooA', 'colB' => 'fooB']);
     $buffer->key()->willReturn(0);
     $buffer->getHeaders()->willReturn(['colA', 'colB']);
     $this->flush($buffer, ['type' => 'csv'], $this->directory . 'output.txt', 2);
     if (!file_exists($this->directory . 'output_1.txt')) {
         throw new FailedPredictionException(sprintf('File "%s" should have been flushed', $this->directory . 'output_1.txt'));
     }
     if (!file_exists($this->directory . 'output_2.txt')) {
         throw new FailedPredictionException(sprintf('File "%s" should have been flushed', $this->directory . 'output_2.txt'));
     }
 }
 function it_flushes_a_buffer_into_multiple_files_with_extension($columnSorter, FlatItemBuffer $buffer, StepExecution $stepExecution, JobParameters $parameters)
 {
     $columnSorter->sort(Argument::any(), [])->willReturn(['colA', 'colB']);
     $stepExecution->getJobParameters()->willReturn($parameters);
     $stepExecution->incrementSummaryInfo('write')->shouldBeCalled();
     $parameters->all()->willReturn([]);
     $buffer->rewind()->willReturn();
     $buffer->count()->willReturn(3);
     $buffer->valid()->willReturn(true, true, true, false);
     $buffer->next()->willReturn();
     $buffer->current()->willReturn(['colA' => 'fooA', 'colB' => 'fooB']);
     $buffer->key()->willReturn(0);
     $buffer->getHeaders()->willReturn(['colA', 'colB']);
     $this->flush($buffer, ['type' => 'csv'], $this->directory . 'output.txt', 2);
     if (!file_exists($this->directory . 'output_1.txt')) {
         throw new FailedPredictionException(sprintf('File "%s" should have been flushed', $this->directory . 'output_1.txt'));
     }
     if (!file_exists($this->directory . 'output_2.txt')) {
         throw new FailedPredictionException(sprintf('File "%s" should have been flushed', $this->directory . 'output_2.txt'));
     }
 }
 /**
  * @param FlatItemBuffer $buffer
  * @param int            $maxLinesPerFile
  *
  * @return bool
  */
 protected function areSeveralFilesNeeded(FlatItemBuffer $buffer, $maxLinesPerFile)
 {
     if (-1 === $maxLinesPerFile) {
         return false;
     }
     return $buffer->count() > $maxLinesPerFile;
 }