Completed
Push — master ( a65293...0f75be )
by Eugene
09:52
created

UuidExtensionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A testPackingAndUnpacking() 0 13 1
1
<?php
2
3
/**
4
 * This file is part of the Tarantool Client package.
5
 *
6
 * (c) Eugene Leonovich <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Tarantool\Client\Tests\Integration\MessagePack;
15
16
use Symfony\Component\Uid\Uuid;
17
use Tarantool\Client\Packer\Extension\UuidExtension;
18
use Tarantool\Client\Packer\PurePacker;
19
use Tarantool\Client\Schema\Criteria;
20
use Tarantool\Client\Tests\Integration\ClientBuilder;
21
use Tarantool\Client\Tests\Integration\TestCase;
22
23
/**
24
 * @requires Tarantool >=2.4
25
 * @requires package symfony/uid
26
 * @requires clientPacker pure
27
 */
28
final class UuidExtensionTest extends TestCase
29
{
30
    /**
31
     * @lua uuid = require('uuid')
32
     * @lua space = create_space('uuid')
33
     * @lua space:create_index("primary", {parts = {1, 'uuid'}})
34
     * @lua space:insert({uuid.fromstr('64d22e4d-ac92-4a23-899a-e59f34af5479')})
35
     */
36
    public function testPackingAndUnpacking() : void
37
    {
38
        $client = ClientBuilder::createFromEnv()
39
            ->setPackerPureFactory(static function () {
40
                return PurePacker::fromExtensions(new UuidExtension());
41
            })
42
            ->build();
43
44
        $space = $client->getSpace('uuid');
45
        $result = $space->select(Criteria::key([new Uuid('64d22e4d-ac92-4a23-899a-e59f34af5479')]));
46
47
        self::assertSame('64d22e4d-ac92-4a23-899a-e59f34af5479', $result[0][0]->toRfc4122());
48
    }
49
}
50