/** * @test */ public function correctFormat() { $file = __DIR__ . "/Teste.xls"; $this->spreadsheetReader = new Spreadsheet_Excel_Reader($file); $this->inputFile = new ExcelInputFile($this->spreadsheetReader); $values = $this->inputFile->getYears(); $this->assertEquals(4, sizeof($values)); $values = $this->inputFile->getValuesFromACountry("Brasil"); $this->assertTrue($this->associativeArrayEquals($this->expectedValuesFromACountry(), $values)); }
private function getDataToSave(ArrayObject &$dataToInsert, ArrayObject $years, ExcelInputFile $inputFile, $country, $subgroup, $font, $type, $variety, $origin, $destiny) { $valuesFromACountry = $inputFile->getValuesFromACountry($country); foreach ($years as $year) { if (isset($valuesFromACountry[$country][$year])) { $value = $valuesFromACountry[$country][$year]; } else { $value = null; } if ($value != null) { $value = (double) str_replace(",", "", $value); $data = $this->buildDataToInsert($year, $subgroup, $font, $type, $variety, $origin, $destiny); $data->setValue($value); $dataToInsert->append($data); } } }