| @@ 23-43 (lines=21) @@ | ||
| 20 | /** |
|
| 21 | * @mixin CurrentDateExecutor |
|
| 22 | */ |
|
| 23 | final class CurrentDateExecutorSpec extends ObjectBehavior |
|
| 24 | { |
|
| 25 | public function it_should_return_current_date(): void |
|
| 26 | { |
|
| 27 | $this()->shouldBeAnInstanceOf(\DateTimeImmutable::class); |
|
| 28 | $this()->shouldBeWithDefaultTimeZone(); |
|
| 29 | $this()->shouldBeCurrentDate(); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function getMatchers(): array |
|
| 33 | { |
|
| 34 | return [ |
|
| 35 | 'beWithDefaultTimeZone' => function (\DateTimeInterface $subject): bool { |
|
| 36 | return $subject->getTimezone()->getName() === date_default_timezone_get(); |
|
| 37 | }, |
|
| 38 | 'beCurrentDate' => function (\DateTimeInterface $subject): bool { |
|
| 39 | return $subject->getTimestamp() === (new \DateTimeImmutable())->setTime(0, 0)->getTimestamp(); |
|
| 40 | }, |
|
| 41 | ]; |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 23-43 (lines=21) @@ | ||
| 20 | /** |
|
| 21 | * @mixin CurrentTimeExecutor |
|
| 22 | */ |
|
| 23 | final class CurrentTimeExecutorSpec extends ObjectBehavior |
|
| 24 | { |
|
| 25 | public function it_should_return_current_time(): void |
|
| 26 | { |
|
| 27 | $this()->shouldBeAnInstanceOf(\DateTimeImmutable::class); |
|
| 28 | $this()->shouldBeWithDefaultTimeZone(); |
|
| 29 | $this()->shouldBeCurrentTime(); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function getMatchers(): array |
|
| 33 | { |
|
| 34 | return [ |
|
| 35 | 'beWithDefaultTimeZone' => function (\DateTimeInterface $subject): bool { |
|
| 36 | return $subject->getTimezone()->getName() === date_default_timezone_get(); |
|
| 37 | }, |
|
| 38 | 'beCurrentTime' => function (\DateTimeInterface $subject): bool { |
|
| 39 | return $subject->getTimestamp() === (new \DateTimeImmutable())->setDate(1, 1, 1)->getTimestamp(); |
|
| 40 | }, |
|
| 41 | ]; |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 23-43 (lines=21) @@ | ||
| 20 | /** |
|
| 21 | * @mixin CurrentTimestampExecutor |
|
| 22 | */ |
|
| 23 | final class CurrentTimestampExecutorSpec extends ObjectBehavior |
|
| 24 | { |
|
| 25 | public function it_should_return_current_timestamp(): void |
|
| 26 | { |
|
| 27 | $this()->shouldBeAnInstanceOf(\DateTimeImmutable::class); |
|
| 28 | $this()->shouldBeWithDefaultTimeZone(); |
|
| 29 | $this()->shouldBeCurrentTimestamp(); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function getMatchers(): array |
|
| 33 | { |
|
| 34 | return [ |
|
| 35 | 'beWithDefaultTimeZone' => function (\DateTimeInterface $subject): bool { |
|
| 36 | return $subject->getTimezone()->getName() === date_default_timezone_get(); |
|
| 37 | }, |
|
| 38 | 'beCurrentTimestamp' => function (\DateTimeInterface $subject): bool { |
|
| 39 | return $subject->getTimestamp() === (new \DateTimeImmutable())->getTimestamp(); |
|
| 40 | }, |
|
| 41 | ]; |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||