fix: added logs instead of exception
This commit is contained in:
2 files changed
+43
-13
No files matched your search
@@ -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 () {
|
||||
|
||||
Reference in new issue
Block a user