Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract GuzzleHttp\Tests\Server into standalone composer package. #2295

Closed
martinssipenko opened this issue May 3, 2019 · 9 comments
Closed
Labels
lifecycle/keep-open Issues that should not be closed

Comments

@martinssipenko
Copy link

Description
Guzzle has a great mock server tooling that is used for testing http requests. I would like to propose to extract the tooling into standalone composer package so that other projects that need similar tooling could benefit from it.

The "mock-server" then could be installed as dev-dependancy and used in tests that need to make http requests.

Currently the only option is to copy/paste the GuzzleHttp\Tests\Server class and server.js files into project, which is not ideal.

I'd be more than happy to contribute, but given this would require a new project setup (repository, composer, ci), I'd like to discuss how this could be achieved. If it's decided to do this, should this be done as part of guzzle organisation? Or if not, is it ok to copy code into different project?

Looking forward to your thoughts.

@Nyholm Nyholm added this to the 7.0.0 milestone Oct 19, 2019
@Nyholm
Copy link
Member

Nyholm commented Oct 19, 2019

Let’s consider this for 7.0

@sagikazarmark
Copy link
Member

@martinssipenko the code is open source, so as long as you retain the original license, you are free to copy the code.

Personally, I think the mock server is a great way to test Guzzle itself, but depending code should rather be covered by integration tests, not unit tests. Also, ideally your HTTP dependencies are abstracted away with some sort of intermediate interface, so your business logic does not actually depend on anything HTTP.

@Nyholm Nyholm modified the milestones: 7.0.0, 8.0.0 Dec 8, 2019
@gmponos
Copy link
Member

gmponos commented Dec 29, 2019

I guess this is related with #2228

@stale
Copy link

stale bot commented Sep 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you for your contributions.

@stale stale bot added the lifecycle/stale No activity for a long time label Sep 25, 2020
@Nyholm Nyholm added the lifecycle/keep-open Issues that should not be closed label Sep 25, 2020
@stale stale bot removed the lifecycle/stale No activity for a long time label Sep 25, 2020
@rhzs
Copy link

rhzs commented Sep 26, 2020

This issue is still relevant, I am using Guzzle ^7.0 but I can't find GuzzleHttp\Tests\Server as the doc mentioned. Why is this issue becoming stale and not relevant??

Screen Shot 2020-09-26 at 15 05 51

@Nyholm
Copy link
Member

Nyholm commented Sep 26, 2020

It issue was incorrectly marked as stale. Sorry for that.

I see that your issue is because you installed the package with composer. Try cloning the repository instead.

@Nyholm
Copy link
Member

Nyholm commented Oct 6, 2021

I've just published https://github.com/guzzle/test-server

I think we should mark this class as deprecated and then remove it in next minor release.
It does not fall under our BC promise but it is a nice gesture for the users.

@martinssipenko
Copy link
Author

I'm closing this issue.

@silverjason
Copy link

silverjason commented Jul 26, 2023

IF anyone is looking for a solution without having to use the test server:

While trying to test a middleware, I used a different way to test it without the test server.
Basically I was able to assign a dummy handler which just returns a fulfilled promise. This replaces the CurlHandler which means it doesn't execute any actual curl request.

  //Assign dummy mock handler to replace CurlHandler
    $mockHandler = function ()  {
        return new FulfilledPromise(new Psr7Response());
    };
    $client = new Client(['handler' => $handlerStack]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/keep-open Issues that should not be closed
Projects
None yet
Development

No branches or pull requests

6 participants