Skip to content

Explain better how to enable the ClockMock annotation #7503

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
Apr 15, 2017

Conversation

javiereguiluz
Copy link
Member

This fixes #7500.

@Jean85
Copy link
Contributor

Jean85 commented Feb 16, 2017

I think that the documentation in this part is a bit lacking. It says that you're enabling the mock in this way, but it's not explicit. It seems at a first glance that in this way your whole test will have mocked time function, when instead it's true only for function calls inside your test method, not outside.

I had to use this a lot when the class that I was testing had time function calls, and I had to dive into the source code to understand that I had to do a manual registration of each class where I want to mock the time function calls.

Maybe it's better to expand this issue's scope?

If you don't want to use the ``@group time-sensitive`` annotation, you can
register the ``ClockMock`` class manually by calling
``ClockMock::register(__CLASS__)`` and ``ClockMock::withClockMock(true)``
before the test and ``ClockMock::withClockMock(false)`` after the test.
Copy link
Contributor

Choose a reason for hiding this comment

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

What about using then instead of repeating and? That might be easier to read.

Copy link
Member Author

@javiereguiluz javiereguiluz Apr 15, 2017

Choose a reason for hiding this comment

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

I don't understand. We say: "do XX and YY before ... and ZZ after ..." Which "and" should I replace by "then" ? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

I would propose:

[...] register the ``ClockMock`` class manually by calling
``ClockMock::register(__CLASS__)`` and ``ClockMock::withClockMock(true)``
before the test then ``ClockMock::withClockMock(false)`` after the test.

wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the new version is less readable 🤓 And this part is hard to read, don't you think? --> the test then

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah it would deserve a comma after test, but I trust you to choose the best way (that includes ignoring my comment :) ).

Copy link
Member Author

@javiereguiluz javiereguiluz Apr 15, 2017

Choose a reason for hiding this comment

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

You are right ... let mergers (@xabbuh ?) deal with this decision and change it if needed :)

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

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

👍

@HeahDude HeahDude added this to the 2.8 milestone Apr 15, 2017
@xabbuh
Copy link
Member

xabbuh commented Apr 15, 2017

Thank you Javier.

@xabbuh xabbuh merged commit 13baa4d into symfony:2.8 Apr 15, 2017
xabbuh added a commit that referenced this pull request Apr 15, 2017
…viereguiluz)

This PR was merged into the 2.8 branch.

Discussion
----------

Explain better how to enable the ClockMock annotation

This fixes #7500.

Commits
-------

13baa4d Explain better how to enable the ClockMock annotation
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.

6 participants