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\Unit; |
15
|
|
|
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
17
|
|
|
use Tarantool\Client\Client; |
18
|
|
|
use Tarantool\Client\Packer\Packer; |
19
|
|
|
use Tarantool\Client\Packer\PurePacker; |
20
|
|
|
|
21
|
|
|
final class ClientFactoryTest extends TestCase |
22
|
|
|
{ |
23
|
|
|
public function testFromDefaultsCreatesClientWithPurePacker() : void |
24
|
|
|
{ |
25
|
|
|
$client = Client::fromDefaults(); |
26
|
|
|
|
27
|
|
|
self::assertInstanceOf(PurePacker::class, $client->getHandler()->getPacker()); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testFromOptionsCreatesClientWithPurePacker() : void |
31
|
|
|
{ |
32
|
|
|
$client = Client::fromOptions(['uri' => 'tcp://tnt']); |
33
|
|
|
|
34
|
|
|
self::assertInstanceOf(PurePacker::class, $client->getHandler()->getPacker()); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testFromOptionsCreatesClientWithCustomPacker() : void |
38
|
|
|
{ |
39
|
|
|
$packer = $this->createMock(Packer::class); |
40
|
|
|
$client = Client::fromOptions(['uri' => 'tcp://tnt'], $packer); |
41
|
|
|
|
42
|
|
|
self::assertSame($packer, $client->getHandler()->getPacker()); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testFromDsnCreatesClientWithPurePacker() : void |
46
|
|
|
{ |
47
|
|
|
$client = Client::fromDsn('tcp://tnt'); |
48
|
|
|
|
49
|
|
|
self::assertInstanceOf(PurePacker::class, $client->getHandler()->getPacker()); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testFromDsnCreatesClientWithCustomPacker() : void |
53
|
|
|
{ |
54
|
|
|
$packer = $this->createMock(Packer::class); |
55
|
|
|
$client = Client::fromDsn('tcp://tnt', $packer); |
56
|
|
|
|
57
|
|
|
self::assertSame($packer, $client->getHandler()->getPacker()); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|