Files

68 lines
2.0 KiB
PHP
Raw Permalink Normal View History

2026-07-20 11:59:20 +03:00
<?php
namespace Tests\Unit\Osint;
use App\Models\Target;
use App\Osint\Runners\GravatarRunner;
use App\Osint\RunnerException;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class GravatarRunnerTest extends TestCase
{
public function test_reports_avatar_found(): void
{
Http::fake(['gravatar.com/avatar/*' => Http::response('', 200)]);
$target = new Target(['type' => 'email', 'value' => 'test@example.com']);
$result = (new GravatarRunner)->run($target);
$this->assertTrue($result->raw['has_avatar']);
$this->assertNotNull($result->raw['avatar_url']);
$this->assertStringContainsString('Gravatar image found', $result->summary);
}
public function test_reports_no_avatar(): void
{
Http::fake(['gravatar.com/avatar/*' => Http::response('', 404)]);
$target = new Target(['type' => 'email', 'value' => 'test@example.com']);
$result = (new GravatarRunner)->run($target);
$this->assertFalse($result->raw['has_avatar']);
$this->assertNull($result->raw['avatar_url']);
$this->assertSame('No Gravatar found for this email.', $result->summary);
}
public function test_rejects_non_email_targets(): void
{
$target = new Target(['type' => 'domain', 'value' => 'example.com']);
$this->expectException(RunnerException::class);
(new GravatarRunner)->run($target);
}
public function test_rejects_invalid_email_format(): void
{
$target = new Target(['type' => 'email', 'value' => 'not-an-email']);
$this->expectException(RunnerException::class);
(new GravatarRunner)->run($target);
}
public function test_throws_on_unexpected_status(): void
{
Http::fake(['gravatar.com/avatar/*' => Http::response('', 500)]);
$target = new Target(['type' => 'email', 'value' => 'test@example.com']);
$this->expectException(RunnerException::class);
(new GravatarRunner)->run($target);
}
}