/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/Clock/Tests/ClockAwareTraitTest.php
44 строки
1 KB
Nicolas Grekas
[Clock] Add `DatePoint`: an immutable DateTime implementation with stricter error handling and return types
26 сен 2023, 19:07
26 сен 2023, 19:07
2f384d1
Код
Авторство
О чём код?
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Clock\ClockAwareTrait; use Symfony\Component\Clock\DatePoint; use Symfony\Component\Clock\MockClock; class ClockAwareTraitTest extends TestCase { public function testTrait() { $sut = new ClockAwareTestImplem(); $this->assertInstanceOf(DatePoint::class, $sut->now()); $clock = new MockClock(); $sut = new $sut(); $sut->setClock($clock); $ts = $sut->now()->getTimestamp(); $this->assertEquals($clock->now(), $sut->now()); $clock->sleep(1); $this->assertEquals($clock->now(), $sut->now()); $this->assertSame(1.0, round($sut->now()->getTimestamp() - $ts, 1)); } } class ClockAwareTestImplem { use ClockAwareTrait { now as public; } }