53 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
// tests/Feature/JobListingTest.php
 | 
						|
namespace Tests\Feature;
 | 
						|
 | 
						|
use PHPUnit\Framework\TestCase;
 | 
						|
 | 
						|
class JobListingTest extends TestCase
 | 
						|
{
 | 
						|
    private $baseUrl = 'http://localhost:20001';
 | 
						|
    
 | 
						|
    public function testHomePageLoads()
 | 
						|
    {
 | 
						|
        $ch = curl_init($this->baseUrl . '/');
 | 
						|
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 | 
						|
        curl_setopt($ch, CURLOPT_HEADER, true);
 | 
						|
        $response = curl_exec($ch);
 | 
						|
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 | 
						|
        curl_close($ch);
 | 
						|
        
 | 
						|
        $this->assertEquals(200, $httpCode, 'Homepage should load successfully');
 | 
						|
        $this->assertStringContainsString('<title>', $response, 'Homepage should have a title');
 | 
						|
    }
 | 
						|
    
 | 
						|
    public function testHealthEndpointReturnsOk()
 | 
						|
    {
 | 
						|
        $ch = curl_init($this->baseUrl . '/health');
 | 
						|
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 | 
						|
        $response = curl_exec($ch);
 | 
						|
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 | 
						|
        curl_close($ch);
 | 
						|
        
 | 
						|
        $this->assertEquals(200, $httpCode, 'Health endpoint should return 200 OK');
 | 
						|
        
 | 
						|
        $data = json_decode($response, true);
 | 
						|
        $this->assertArrayHasKey('status', $data, 'Health response should have status field');
 | 
						|
        $this->assertEquals('ok', $data['status'], 'Health status should be ok');
 | 
						|
    }
 | 
						|
    
 | 
						|
    public function testPositionsEndpointReturnsJson()
 | 
						|
    {
 | 
						|
        $ch = curl_init($this->baseUrl . '/positions');
 | 
						|
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 | 
						|
        $response = curl_exec($ch);
 | 
						|
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 | 
						|
        curl_close($ch);
 | 
						|
        
 | 
						|
        $this->assertEquals(200, $httpCode, 'Positions endpoint should return 200 OK');
 | 
						|
        
 | 
						|
        $data = json_decode($response, true);
 | 
						|
        $this->assertArrayHasKey('positions', $data, 'Positions response should have positions field');
 | 
						|
        $this->assertIsArray($data['positions'], 'Positions should be an array');
 | 
						|
    }
 | 
						|
} |