MonotonicClock example

use PHPUnit\Framework\TestCase;
use Symfony\Component\Clock\MonotonicClock;

/** * @group time-sensitive */
class MonotonicClockTest extends TestCase
{
    public function testConstruct()
    {
        $clock = new MonotonicClock('UTC');
        $this->assertSame('UTC', $clock->now()->getTimezone()->getName());

        $tz = date_default_timezone_get();
        $clock = new MonotonicClock();
        $this->assertSame($tz$clock->now()->getTimezone()->getName());

        $clock = new MonotonicClock(new \DateTimeZone($tz));
        $this->assertSame($tz$clock->now()->getTimezone()->getName());
    }

    public function testNow()
    {
Home | Imprint | This part of the site doesn't use cookies.