Files
php-uuid/tests/Provider/Time/FixedTimeProviderTest.php
T
Ben Ramsey 0d7b8c2b7a Update coding style to include PSR-12, among other options
This also includes heavy use of slevomat/coding-standard to apply
various checks to the code, based on maintainer (me) preference.
2020-01-18 12:13:55 -06:00

37 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Ramsey\Uuid\Test\Provider\Time;
use Ramsey\Uuid\Provider\Time\FixedTimeProvider;
use Ramsey\Uuid\Test\TestCase;
class FixedTimeProviderTest extends TestCase
{
public function testConstructorRequiresSecAndUsec(): void
{
$this->expectException(\InvalidArgumentException::class);
$provider = new FixedTimeProvider([]);
}
public function testCurrentTimeReturnsTimestamp(): void
{
$timestamp = ['sec' => 1458844556, 'usec' => 200997];
$provider = new FixedTimeProvider($timestamp);
$this->assertEquals($timestamp, $provider->currentTime());
}
public function testCurrentTimeReturnsTimestampAfterChange(): void
{
$timestamp = ['sec' => 1458844556, 'usec' => 200997];
$provider = new FixedTimeProvider($timestamp);
$newTimestamp = ['sec' => 1050804050, 'usec' => 30192];
$provider->setSec($newTimestamp['sec']);
$provider->setUsec($newTimestamp['usec']);
$this->assertEquals($newTimestamp, $provider->currentTime());
}
}