ClockAwareTestImplem example

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());
        
Home | Imprint | This part of the site doesn't use cookies.