the middle of the idiots
This commit is contained in:
		
							
								
								
									
										53
									
								
								qwen/php/tests/Feature/JobListingTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								qwen/php/tests/Feature/JobListingTest.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
<?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');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user