You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #48098 [HttpKernel] Resolve DateTime value using the Clock (GromNaN)
This PR was merged into the 6.3 branch.
Discussion
----------
[HttpKernel] Resolve DateTime value using the Clock
| Q | A
| ------------- | ---
| Branch? | 6.3
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | TODO
In order to mock the current time in functional test cases by injecting a `Symfony\Component\Clock\MockClock` as `clock` service. This is necessary when a `DateTimeInterface` argument is not nullable and we expect the current date time by default.
Example when 2 routes are configured on the same controller with an optional parameter.
```php
class TvGridController
{
#[Route('/', name: 'prime_now')]
#[Route('/{date}', name: 'prime_date']
public function prime(\DateTimeInterface $date)
{
return new Response('Grid for date: '.$date->format('Y-m-d'));
}
}
```
Commits
-------
4917528d9a Resolve DateTime value using the clock
0 commit comments