Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MockResponse total_time should not be simulated when provided #40239

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

Merged
merged 1 commit into from
Feb 26, 2021
Merged

MockResponse total_time should not be simulated when provided #40239

merged 1 commit into from
Feb 26, 2021

Conversation

pvgnd
Copy link
Contributor

@pvgnd pvgnd commented Feb 18, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

When you provide a total_time to a MockResponse, it is overriden. It should be simulated only when it is not provided I guess.
Ex: new MockResponse('{"foo":"bar"}', ['total_time' => 0.4])

@pvgnd pvgnd changed the base branch from 5.x to 5.2 February 18, 2021 14:06
@nicolas-grekas nicolas-grekas changed the title fix: MockResponse total_time should not be simulated when provided [HttpClient] MockResponse total_time should not be simulated when provided Feb 18, 2021
@carsonbot
Copy link

Hey!

Two days ago, I was sitting at my usual spot at the top of Big Ben, I was thinking that we really needed this. And now, here you are with a PR. =)

I think @javespi has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

Copy link
Contributor

@javespi javespi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to me 👍

Comment on lines -311 to 292
if (isset($response->info['total_time'])) {
if (!isset($response->info['total_time'])) {
$response->info['total_time'] = microtime(true) - $response->info['start_time'];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To measure the time that passes between the two calls.

@carsonbot carsonbot changed the title [HttpClient] MockResponse total_time should not be simulated when provided MockResponse total_time should not be simulated when provided Feb 21, 2021
@nicolas-grekas nicolas-grekas added this to the 5.2 milestone Feb 22, 2021
@nicolas-grekas
Copy link
Member

This should target 4.4, since the bug exists there, isn't it?
Can you please rebase, and maybe add a test case?

@pvgnd pvgnd changed the base branch from 5.2 to 4.4 February 25, 2021 17:59
@pvgnd
Copy link
Contributor Author

pvgnd commented Feb 25, 2021

This should target 4.4, since the bug exists there, isn't it?
Can you please rebase, and maybe add a test case?

Done

@nicolas-grekas nicolas-grekas modified the milestones: 5.2, 4.4 Feb 25, 2021
@nicolas-grekas
Copy link
Member

Thank you @pvgnd.

@nicolas-grekas nicolas-grekas merged commit a5683c5 into symfony:4.4 Feb 26, 2021
This was referenced Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants