<?php

namespace Tests\Unit;

use App\Support\MobileUserAgent;
use Illuminate\Http\Request;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;

class MobileUserAgentTest extends TestCase
{
    #[DataProvider('userAgents')]
    public function test_matches_mobile_user_agents(string $userAgent, bool $expected): void
    {
        $request = Request::create('/', 'GET', [], [], [], [
            'HTTP_USER_AGENT' => $userAgent,
        ]);

        $this->assertSame($expected, MobileUserAgent::matches($request));
    }

    public static function userAgents(): array
    {
        return [
            'android chrome' => [
                'Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 Chrome/120.0.0.0 Mobile Safari/537.36',
                true,
            ],
            'desktop chrome' => [
                'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 Chrome/120.0.0.0 Safari/537.36',
                false,
            ],
            'empty' => ['', false],
        ];
    }
}
