mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-15 16:07:55 +03:00
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Provider\Node;
|
||||
|
||||
use AspectMock\Test as AspectMock;
|
||||
use Exception;
|
||||
use Ramsey\Uuid\Exception\RandomSourceException;
|
||||
use Ramsey\Uuid\Provider\Node\RandomNodeProvider;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
|
||||
@@ -110,4 +112,22 @@ class RandomNodeProviderTest extends TestCase
|
||||
|
||||
$this->assertSame('010000000000', $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testGetNodeThrowsExceptionWhenExceptionThrownByRandombytes(): void
|
||||
{
|
||||
AspectMock::func('Ramsey\Uuid\Provider\Node', 'random_bytes', function (): void {
|
||||
throw new Exception('Could not gather sufficient random data');
|
||||
});
|
||||
|
||||
$provider = new RandomNodeProvider();
|
||||
|
||||
$this->expectException(RandomSourceException::class);
|
||||
$this->expectExceptionMessage('Could not gather sufficient random data');
|
||||
|
||||
$provider->getNode();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user