/** * @dataProvider getReaders */ public function testGetHeaders(Reader $reader) { $this->assertEquals(array("column1", "column2", "column3"), $reader->getHeaders()->toPrimitiveArray()); }
/** * Realiza la revision del archivo * * @param string $fileName */ protected function initialize(Reader $reader) { $this->checkCsvFile($reader->getFilename()); if (count($this->rules) === 0) { throw new Exception(' No se puede revistar el documento sin antes haber definido reglas @ ' . __LINE__); } $index = $reader->getHeaders(); if (count($this->index) > 0) { $faltan = array_diff($this->index, $index); if (count($faltan)) { $this->addError('Se detectaron columnas faltantes en el archivo, se necesitan ' . implode(', ', $this->index) . ' y se encontraron ' . implode(', ', $index) . ' Faltando ' . implode(', ', $faltan) . ''); } } $reader->rewind(); while ($reader->valid()) { $this->applyRules($reader->current(), $reader->getLineNumber()); $reader->next(); } }