OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
ramsey
/
uuid
/
tests
/
Generator
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/12/2024 10:36:11 AM
rwxr-xr-x
📄
CombGeneratorTest.php
4.65 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
DceSecurityGeneratorTest.php
11.4 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
DefaultNameGeneratorTest.php
2.48 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
DefaultTimeGeneratorTest.php
6.88 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
NameGeneratorFactoryTest.php
464 bytes
08/12/2024 10:34:38 AM
rw-r--r--
📄
PeclUuidNameGeneratorTest.php
3.48 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
PeclUuidRandomGeneratorTest.php
757 bytes
08/12/2024 10:34:38 AM
rw-r--r--
📄
PeclUuidTimeGeneratorTest.php
747 bytes
08/12/2024 10:34:38 AM
rw-r--r--
📄
RandomBytesGeneratorTest.php
1.89 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
RandomGeneratorFactoryTest.php
498 bytes
08/12/2024 10:34:38 AM
rw-r--r--
📄
RandomLibAdapterTest.php
2.28 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
TimeGeneratorFactoryTest.php
1.21 KB
08/12/2024 10:34:38 AM
rw-r--r--
📄
UnixTimeGeneratorTest.php
7.36 KB
08/12/2024 10:34:38 AM
rw-r--r--
Editing: RandomBytesGeneratorTest.php
Close
<?php declare(strict_types=1); namespace Ramsey\Uuid\Test\Generator; use Exception; use Ramsey\Uuid\Exception\RandomSourceException; use Ramsey\Uuid\Generator\RandomBytesGenerator; use Ramsey\Uuid\Test\TestCase; use phpmock\mockery\PHPMockery; use function hex2bin; class RandomBytesGeneratorTest extends TestCase { /** * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification */ public function lengthAndHexDataProvider(): array { return [ [6, '4f17dd046fb8'], [10, '4d25f6fe5327cb04267a'], [12, '1ea89f83bd49cacfdf119e24'], ]; } /** * @param int<1, max> $length * * @throws Exception * * @dataProvider lengthAndHexDataProvider * @runInSeparateProcess * @preserveGlobalState disabled */ public function testGenerateReturnsRandomBytes(int $length, string $hex): void { $bytes = hex2bin($hex); PHPMockery::mock('Ramsey\Uuid\Generator', 'random_bytes') ->once() ->with($length) ->andReturn($bytes); $generator = new RandomBytesGenerator(); $this->assertSame($bytes, $generator->generate($length)); } /** * @runInSeparateProcess * @preserveGlobalState disabled */ public function testGenerateThrowsExceptionWhenExceptionThrownByRandombytes(): void { PHPMockery::mock('Ramsey\Uuid\Generator', 'random_bytes') ->once() ->with(16) ->andThrow(new Exception('Could not gather sufficient random data')); $generator = new RandomBytesGenerator(); $this->expectException(RandomSourceException::class); $this->expectExceptionMessage('Could not gather sufficient random data'); $generator->generate(16); } }