mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-18 16:37:43 +03:00
Optimize codec algorithms
This commit is contained in:
@@ -4,10 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Codec;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Ramsey\Uuid\Builder\UuidBuilderInterface;
|
||||
use Ramsey\Uuid\Codec\StringCodec;
|
||||
use Ramsey\Uuid\Rfc4122\Fields;
|
||||
use Ramsey\Uuid\Rfc4122\FieldsInterface;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
@@ -68,10 +70,13 @@ class StringCodecTest extends TestCase
|
||||
public function testEncodeBinaryReturnsBinaryString(): void
|
||||
{
|
||||
$expected = hex2bin('123456781234abcdabef1234abcd4321');
|
||||
$this->uuid->method('getHex')
|
||||
->willReturn('123456781234abcdabef1234abcd4321');
|
||||
$this->uuid->method('getBytes')
|
||||
->willReturn(hex2bin('123456781234abcdabef1234abcd4321'));
|
||||
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
'getBytes' => hex2bin('123456781234abcdabef1234abcd4321'),
|
||||
]);
|
||||
|
||||
$this->uuid->method('getFields')->willReturn($fields);
|
||||
|
||||
$codec = new StringCodec($this->builder);
|
||||
$result = $codec->encodeBinary($this->uuid);
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
Reference in New Issue
Block a user