cakephp / docs

CakePHP CookBook
http://book.cakephp.org
Other
679 stars 2.58k forks source link

Missing documentation for testing the HTTP API calls #6892

Closed ishan-biztech closed 3 years ago

ishan-biztech commented 3 years ago

Issue Description

Currently we are missing documentation on how to test HTTP/Curl API calls in CakePHP. It's not clear like what is an best practice to test these http request.

  1. Is there any helper methods or anything that helps developers test this in CakePHP way?
  2. Is there any other way around that experienced developers are doing to test their HTTP request?

In above both cases we should add some content(along with some pseudo code) to let developers know what is the recommended way of doing this.


Do you want to address this issue?

I might but I don't actually know what is the best practice to test HTTP calls in CakePHP yet! Also I can't find much of a content on this topic.

markstory commented 3 years ago

Are you looking for how to test the outbound API calls your application is making, or are you wanting to test requests being made to your application?

ishan-biztech commented 3 years ago

Outbound API calls like making calls to Stripe or Xero API, etc. Currently it's not documented like how to do this(or what is the recommended way I should say).

For example if you look at Laravel docs, they have dedicated section on how to mock HTTP requests made by Laravel's Illuminate\Support\Facades\Http client.

markstory commented 3 years ago

Ok. We don't currently have a high level API for faking outbound requests. I've used php-vcr for stubbing network requests in the past. I wrote a blog post about how to get it setup with a CakePHP application.

We might want to add a simpler to use wrapper/API for this in CakePHP itself though.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

ishan-biztech commented 3 years ago

Hi @markstory, are you able to assign any milestone or something to this feature? To prevent from being closed?

theafolayan commented 3 years ago

Is someone intending to work on this yet? Looking to take this up soon.

markstory commented 3 years ago

@theafolayan I don't think there has been any movement on this. I have been preoccupied with fixtures and haven't gotten to this yet. If you have time an issue with the proposed API you are considering would be a great place to start.

rochamarcelo commented 3 years ago

What is the status here? Maybe we could add some basic examples in the doc of how to mock using mock builder. The changes would be in the page https://book.cakephp.org/4/en/development/testing.html

markstory commented 3 years ago

This can be closed now. The new features will be part of 4.3 and the docs are in the 4.next branch of this repo.