<?php

use PHPUnit\Framework\TestCase;
use App\Services\AuthService;

class LoginTest extends TestCase
{
    private AuthService $authService;

    protected function setUp(): void
    {
        $this->authService = new AuthService();
    }

    public function testLoginWithInvalidCredentials(): void
    {
        $this->expectException(Exception::class);

        $this->authService->login(
            'fakeuser',
            'wrongpassword',
            'FAKE-LICENSE'
        );
    }

    public function testLoginWithValidCredentials(): void
    {
        $result = $this->authService->login(
            'demo',
            '123456',
            'LIC-ABC-123'
        );

        $this->assertArrayHasKey('token', $result);
        $this->assertArrayHasKey('expires_in', $result);
        $this->assertIsString($result['token']);
    }
}
