|
14 | 14 |
|
15 | 15 | expect($response->json('logs'))->toHaveCount(count($logEntries)); |
16 | 16 | }); |
| 17 | + |
| 18 | +test('simple characters can be searched case-insensitive', function () { |
| 19 | + $logEntries = [ |
| 20 | + makeLaravelLogEntry(message: 'error'), |
| 21 | + makeLaravelLogEntry(message: 'Error'), |
| 22 | + makeLaravelLogEntry(message: 'eRrOr'), |
| 23 | + makeLaravelLogEntry(message: 'ERROR'), |
| 24 | + makeLaravelLogEntry(message: 'simple text'), |
| 25 | + ]; |
| 26 | + $file = generateLogFile('logsearchtest.log', implode(PHP_EOL, $logEntries)); |
| 27 | + |
| 28 | + // first, just to be sure that we're getting all the logs without any query |
| 29 | + $response = getJson(route('log-viewer.logs', ['file' => $file->identifier])); |
| 30 | + expect($response->json('logs'))->toHaveCount(count($logEntries)); |
| 31 | + |
| 32 | + // now, with the query. Re-instantiate the log reader to make sure we don't have anything cached. |
| 33 | + \Opcodes\LogViewer\Readers\IndexedLogReader::clearInstance($file); |
| 34 | + $response = getJson(route('log-viewer.logs', [ |
| 35 | + 'file' => $file->identifier, |
| 36 | + 'query' => 'error', |
| 37 | + ])); |
| 38 | + expect($response->json('logs'))->toHaveCount(4); |
| 39 | + |
| 40 | +}); |
| 41 | + |
| 42 | +test('unicode characters can be searched case-insensitive', function () { |
| 43 | + $logEntries = [ |
| 44 | + makeLaravelLogEntry(message: 'ошибка'), |
| 45 | + makeLaravelLogEntry(message: 'Ошибка'), |
| 46 | + makeLaravelLogEntry(message: 'ошибкА'), |
| 47 | + makeLaravelLogEntry(message: 'ОШИБКА'), |
| 48 | + makeLaravelLogEntry(message: 'simple text'), |
| 49 | + ]; |
| 50 | + $file = generateLogFile('logunicodetest.log', implode(PHP_EOL, $logEntries)); |
| 51 | + |
| 52 | + // first, just to be sure that we're getting all the logs without any query |
| 53 | + $response = getJson(route('log-viewer.logs', ['file' => $file->identifier])); |
| 54 | + expect($response->json('logs'))->toHaveCount(count($logEntries)); |
| 55 | + |
| 56 | + // now, with the query. Re-instantiate the log reader to make sure we don't have anything cached. |
| 57 | + \Opcodes\LogViewer\Readers\IndexedLogReader::clearInstance($file); |
| 58 | + $response = getJson(route('log-viewer.logs', [ |
| 59 | + 'file' => $file->identifier, |
| 60 | + 'query' => 'ошибка', |
| 61 | + ])); |
| 62 | + expect($response->json('logs'))->toHaveCount(4); |
| 63 | +}); |
0 commit comments