mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-15 16:07:55 +03:00
Fix: Move tests one up
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Ramsey\Uuid\Test\Generator;
|
||||
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Generator\SodiumRandomGenerator;
|
||||
|
||||
class SodiumRandomGeneratorTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded('libsodium')) {
|
||||
$this->markTestSkipped(
|
||||
'The libsodium extension is not available.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateReturnsBytes()
|
||||
{
|
||||
$generator = new SodiumRandomGenerator();
|
||||
|
||||
$bytes = $generator->generate(16);
|
||||
|
||||
$this->assertInternalType('string', $bytes);
|
||||
$this->assertEquals(16, strlen($bytes));
|
||||
}
|
||||
|
||||
public function testFactoryUsesSodiumRandomGenerator()
|
||||
{
|
||||
$uuidFactory = new \Ramsey\Uuid\UuidFactory();
|
||||
$uuidFactory->setRandomGenerator(new SodiumRandomGenerator());
|
||||
\Ramsey\Uuid\Uuid::setFactory($uuidFactory);
|
||||
|
||||
$uuid = \Ramsey\Uuid\Uuid::uuid4();
|
||||
|
||||
$this->assertInstanceOf(
|
||||
'Ramsey\Uuid\Generator\SodiumRandomGenerator',
|
||||
$uuid->getFactory()->getRandomGenerator()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user