Files
php-uuid/tests/Provider/Time/SystemTimeProviderTest.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

35 lines
961 B
PHP

<?php
declare(strict_types=1);
namespace Ramsey\Uuid\Test\Provider\Time;
use AspectMock\Test as AspectMock;
use Ramsey\Uuid\Provider\Time\SystemTimeProvider;
use Ramsey\Uuid\Test\TestCase;
class SystemTimeProviderTest extends TestCase
{
public function testCurrentTimeReturnsTimestampArray(): void
{
$provider = new SystemTimeProvider();
$time = $provider->currentTime();
$this->assertArrayHasKey('sec', $time);
$this->assertArrayHasKey('usec', $time);
}
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testCurrentTimeUsesGettimeofday(): void
{
$timestamp = ['sec' => 1458844556, 'usec' => 200997];
$func = AspectMock::func('Ramsey\Uuid\Provider\Time', 'gettimeofday', $timestamp);
$provider = new SystemTimeProvider();
$this->assertSame($timestamp, $provider->currentTime());
$func->verifyInvokedOnce();
}
}