Files
php-uuid/tests/Generator/PeclUuidRandomGeneratorTest.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

50 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace Ramsey\Uuid\Test\Generator;
use AspectMock\Test as AspectMock;
use Ramsey\Uuid\Generator\PeclUuidRandomGenerator;
class PeclUuidRandomGeneratorTest extends PeclUuidTestCase
{
/**
* @var int
*/
private $length = 10;
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testGenerateCreatesUuidUsingPeclUuidMethods(): void
{
$create = AspectMock::func('Ramsey\Uuid\Generator', 'uuid_create', $this->uuidString);
$parse = AspectMock::func('Ramsey\Uuid\Generator', 'uuid_parse', $this->uuidBinary);
$generator = new PeclUuidRandomGenerator();
$uuid = $generator->generate($this->length);
$this->assertEquals($this->uuidBinary, $uuid);
$create->verifyInvoked([UUID_TYPE_RANDOM]);
$parse->verifyInvoked([$this->uuidString]);
}
/**
* This test is for the return type of the generate method
* It ensures that the generate method returns whatever value uuid_parse returns.
*/
public function testGenerateReturnsUuidString(): void
{
$create = AspectMock::func('Ramsey\Uuid\Generator', 'uuid_create', $this->uuidString);
$parse = AspectMock::func('Ramsey\Uuid\Generator', 'uuid_parse', $this->uuidBinary);
$generator = new PeclUuidRandomGenerator();
$uuid = $generator->generate($this->length);
$this->assertEquals($this->uuidBinary, $uuid);
$create->verifyInvoked([UUID_TYPE_RANDOM]);
$parse->verifyInvoked([$this->uuidString]);
}
}