$colA * @param list $numericRows */ function makeXlsx(array $colA, array $numericRows = []): string { $ss = new Spreadsheet; $sheet = $ss->getActiveSheet(); foreach ($colA as $i => $v) { $ref = 'A'.($i + 1); if (in_array($i, $numericRows, true)) { $sheet->setCellValueExplicit($ref, $v, DataType::TYPE_NUMERIC); } else { $sheet->setCellValueExplicit($ref, $v, DataType::TYPE_STRING); } } $path = tempnam(sys_get_temp_dir(), 'xlsxtest').'.xlsx'; (new XlsxWriter($ss))->save($path); return $path; } it('читает номера из первой колонки и пропускает заголовок', function () { $path = makeXlsx(['Телефон', '+7 913 519-12-64', '89135191264']); $rows = (new ClientSmsPhoneFileReader)->read($path); expect($rows)->toBe(['+7 913 519-12-64', '89135191264']); @unlink($path); }); it('без заголовка читает все строки', function () { $path = makeXlsx(['79001234567', '79007654321']); $rows = (new ClientSmsPhoneFileReader)->read($path); expect($rows)->toBe(['79001234567', '79007654321']); @unlink($path); }); it('номер, записанный как число, не уходит в научную нотацию', function () { $path = makeXlsx(['79135191264'], numericRows: [0]); $rows = (new ClientSmsPhoneFileReader)->read($path); expect($rows)->toBe(['79135191264']); @unlink($path); }); it('пропускает пустые ячейки', function () { $path = makeXlsx(['79001234567', '', ' ', '79007654321']); $rows = (new ClientSmsPhoneFileReader)->read($path); expect($rows)->toBe(['79001234567', '79007654321']); @unlink($path); });