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

Skip to content

[Messenger] Use now function to allow mock of time #53531

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

Closed
wants to merge 1 commit into from

Conversation

andersonamuller
Copy link
Contributor

@andersonamuller andersonamuller commented Jan 12, 2024

Q A
Branch? 7.1
Bug fix? no
New feature? no
Deprecations? no
Issues N/A
License MIT

When doing functional testing there is not really a easy way to mock the time for the InMemoryTransport. It's created by the InMemoryTransportFactory and you can't set which clock to use.

When doing functional testing there is not really a easy way to mock the time for the `InMemoryTransport`. It's created by the `InMemoryTransportFactory` and you can't set which clock to use.
@carsonbot carsonbot added this to the 6.4 milestone Jan 12, 2024
@andersonamuller andersonamuller changed the title Use now function to allow mock of time [Messenger] Use now function to allow mock of time Jan 12, 2024
@carsonbot carsonbot changed the title [Messenger] Use now function to allow mock of time Use now function to allow mock of time Jan 30, 2024
@ro0NL

This comment was marked as resolved.

@andersonamuller
Copy link
Contributor Author

however i think we should inject global clock into InMemoryTransportFactory isnt it?

Yes, that is the best solution indeed

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

I don't believe that this is the right way. If the transport already receives a clock, we should rather leverage the injected clock for mocking than introduce a second way of accessing mocked date values.

@nicolas-grekas nicolas-grekas modified the milestones: 6.4, 7.1 Apr 11, 2024
@nicolas-grekas nicolas-grekas changed the title Use now function to allow mock of time [Messenger] Use now function to allow mock of time Apr 11, 2024
@nicolas-grekas
Copy link
Member

It's created by the InMemoryTransportFactory and you can't set which clock to use.

I'd rather fix this aspect indeed: making the InMemoryTransportFactory accept and forward a clock.

PR welcome.

fabpot added a commit that referenced this pull request Apr 17, 2024
…MemoryTransport (xabbuh)

This PR was merged into the 7.1 branch.

Discussion
----------

[Messenger] forward a Clock instance to the created InMemoryTransport

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Issues        | Fix #53531 (comment)
| License       | MIT

Commits
-------

1cfd8b5 forward a Clock instance to the created InMemoryTransport
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Apr 17, 2024
…MemoryTransport (xabbuh)

This PR was merged into the 7.1 branch.

Discussion
----------

[Messenger] forward a Clock instance to the created InMemoryTransport

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Issues        | Fix symfony/symfony#53531 (comment)
| License       | MIT

Commits
-------

1cfd8b57e9 forward a Clock instance to the created InMemoryTransport
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