John Davidson

php - cURL error 3 on Symfony on symfony API testing with Phpunit

0 comments
Message:


I'm making a test for an API enpoint but I'm geting an error


public function testRequest(): void
{

$client = new Client([
'base_url' => 'http://localhost:8000',
'defaults' => [
'exceptions' => false
]
]);

$response = $client->get('/api/products');
$this->assertEquals(200, $response->getStatusCode());
}

I get this error


1) App\Tests\Controller\ApiControllerTest::testRequest        
GuzzleHttp\Exception\RequestException: cURL error 3: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for /api/products

The tested endpoint url is http://localhost:8000/api/products I think the on the test y correct



My Answer:
> It looks like your code snippet is incomplete. Can you provide the full code for the testRequest function so I can better understand the issue and provide a solution?

Rate this post

4 of 5 based on 7126 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us