withoutMiddleware( ThrottleRequests::class ); // $this->faker = \Faker\Factory::create(); // $this->makeTestData(); $this->withoutExceptionHandling(); } public function testCsvRead() { $csv = file_get_contents(base_path().'/tests/Feature/Import/invoice.csv'); $this->assertTrue(is_array($this->getCsvData($csv))); } private function getCsvData($csvfile) { if (! ini_get('auto_detect_line_endings')) { ini_set('auto_detect_line_endings', '1'); } $csv = Reader::createFromString($csvfile); $stmt = new Statement(); $data = iterator_to_array($stmt->process($csv)); if (count($data) > 0) { $headers = $data[0]; // Remove Invoice Ninja headers if (count($headers) && count($data) > 4) { $firstCell = $headers[0]; if (strstr($firstCell, config('ninja.app_name'))) { array_shift($data); // Invoice Ninja... array_shift($data); // array_shift($data); // Enitty Type Header } } } return $data; } }