public function testRandomUuid()
{
$this->specify("uuid does not created a properly formatted UUID", function () {
$random = new Random();
$isValid = function ($uuid) {
return preg_match('/^\\{?[0-9a-f]{8}\\-?[0-9a-f]{4}\\-?[0-9a-f]{4}\\-?[0-9a-f]{4}\\-?[0-9a-f]{12}\\}?$/i', $uuid) === 1;
};
for ($i = 0; $i <= 10; $i++) {
$actual = $random->uuid();
expect($isValid($actual))->true();
expect(substr($actual, 14, 1))->equals(4);
expect(in_array(substr($actual, 19, 1), ['8', '9', 'a', 'b']))->true();
}
});
}