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

Fixing broken integration tests #247

Merged
merged 2 commits into from Apr 12, 2018

Conversation

moufmouf
Copy link
Contributor

Context

Integration tests are broken.
This seems to be due to a change in Travis.yml.

Indeed, when Travis performs 2 HTTP requests, for some reason, the "Origin" IP of the request is changing between the request.

This is really a Travis issue and not a PHP-VCR issue;
To make sure of this, I've changed .travis.yml and ran twice the "curl http://httpbin.org/get". Here is the output I got:

$ curl http://httpbin.org/get
{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3"
  }, 
  "origin": "35.202.145.110", 
  "url": "http://httpbin.org/get"
}
The command "curl http://httpbin.org/get" exited with 0.
$ curl http://httpbin.org/get
{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3"
  }, 
  "origin": "35.184.226.236", 
  "url": "http://httpbin.org/get"
}

See? Twice the same request and 2 different "origin".
This is wreaking havok in the unit tests.

What has been done

First, I removed the "origin" from the JSON.
Then I realized that the integration tests were not actually testing whether PHP-VCR is working really or not. I mean that if PHP-VCR was actually doing nothing (and simply acting like a pass-through), the tests would still succeed.

So I rewrote the "GET" test and made it point to "http://api.chew.pro/trbmb". This is an API that generates random data.

This way, I can test that PHP-VCR is actually really replaying the request (because if it acts as a pass-through, I would get different data for each request.

@renatomefi
Copy link
Member

hello @moufmouf
Thanks a lot for fixing it! The tests got a bit less readable but it isn't your fault!
I'll merge this right away so you can continue what you were doing :)

Thanks again

@renatomefi renatomefi merged commit 4087b41 into php-vcr:master Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants