the beginning of the idiots
This commit is contained in:
		
							
								
								
									
										44
									
								
								qwen/php/tests/Auth/AuthServiceTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								qwen/php/tests/Auth/AuthServiceTest.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
<?php
 | 
			
		||||
// tests/Auth/AuthServiceTest.php
 | 
			
		||||
namespace Tests\Auth;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use App\Auth\AuthService;
 | 
			
		||||
 | 
			
		||||
class AuthServiceTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    private $authService;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->authService = new AuthService();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testCreateJWT(): void
 | 
			
		||||
    {
 | 
			
		||||
        $payload = ['user_id' => 'test_user', 'email' => 'test@example.com'];
 | 
			
		||||
        $token = $this->authService->createJWT($payload);
 | 
			
		||||
        
 | 
			
		||||
        $this->assertIsString($token);
 | 
			
		||||
        $this->assertNotEmpty($token);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testVerifyJWT(): void
 | 
			
		||||
    {
 | 
			
		||||
        $payload = ['user_id' => 'test_user', 'email' => 'test@example.com'];
 | 
			
		||||
        $token = $this->authService->createJWT($payload);
 | 
			
		||||
        
 | 
			
		||||
        $decoded = $this->authService->verifyJWT($token);
 | 
			
		||||
        
 | 
			
		||||
        $this->assertIsArray($decoded);
 | 
			
		||||
        $this->assertEquals('test_user', $decoded['user_id']);
 | 
			
		||||
        $this->assertEquals('test@example.com', $decoded['email']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testVerifyInvalidJWT(): void
 | 
			
		||||
    {
 | 
			
		||||
        $result = $this->authService->verifyJWT('invalid_token');
 | 
			
		||||
        
 | 
			
		||||
        $this->assertNull($result);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user