fix: added logs instead of exception

This commit is contained in:
mathiaspalmqvist committed 2026-01-03 14:55:34 +01:00
1 parent f25b67f6f1
commit 630620e4e6
2 files changed
+43 -13

No files matched your search

+22 -4
View File
@@ -60,12 +60,30 @@ it('uses hardcoded timeout', function () {
});
});
it('validates required data fields', function () {
it('skips sending when required data fields are missing', function () {
$client = new AnalyticsClient;
expect(fn () => $client->send([]))->toThrow(InvalidArgumentException::class)
->and(fn () => $client->send(['k' => 'test']))->toThrow(InvalidArgumentException::class)
->and(fn () => $client->send(['k' => 'test', 'u' => 'url', 'ip' => '1.1.1.1']))->toThrow(InvalidArgumentException::class);
// Should not throw exceptions, just skip silently
$client->send([]);
$client->send(['k' => 'test']);
$client->send(['k' => 'test', 'u' => 'url', 'ip' => '1.1.1.1']);
// No HTTP requests should be sent for invalid data
Http::assertNothingSent();
});
it('skips sending when URL exceeds 512 characters', function () {
$client = new AnalyticsClient;
$longUrl = 'https://example.com/'.str_repeat('a', 500);
$client->send([
'k' => 'testsiteky',
'u' => $longUrl,
'ip' => '192.168.1.1',
'ua' => 'Mozilla/5.0 Chrome',
]);
Http::assertNothingSent();
});
it('filters out empty referrer URLs', function () {