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\Connection; |
15
|
|
|
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
17
|
|
|
use Tarantool\Client\Connection\StreamConnection; |
18
|
|
|
|
19
|
|
|
final class StreamConnectionTest extends TestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideConnectionArrayOptionsOfValidTypes |
23
|
|
|
* @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideTcpExtraConnectionArrayOptionsOfValidTypes |
24
|
|
|
* @doesNotPerformAssertions |
25
|
|
|
*/ |
26
|
|
|
public function testCreateTcpAcceptsOptionOfValidType(string $optionName, $optionValue) : void |
27
|
|
|
{ |
28
|
|
|
StreamConnection::createTcp(StreamConnection::DEFAULT_TCP_URI, [$optionName => $optionValue]); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideConnectionArrayOptionsOfValidTypes |
33
|
|
|
* @doesNotPerformAssertions |
34
|
|
|
*/ |
35
|
|
|
public function testCreateUdsAcceptsOptionOfValidType(string $optionName, $optionValue) : void |
36
|
|
|
{ |
37
|
|
|
StreamConnection::createUds('unix:///socket.sock', [$optionName => $optionValue]); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideConnectionArrayOptionsOfInvalidTypes |
42
|
|
|
* @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideTcpExtraConnectionArrayOptionsOfInvalidTypes |
43
|
|
|
*/ |
44
|
|
|
public function testCreateTcpRejectsOptionOfInvalidType(string $optionName, $optionValue, string $expectedType) : void |
45
|
|
|
{ |
46
|
|
|
$this->expectException(\TypeError::class); |
47
|
|
|
$this->expectExceptionMessageMatches("/must be of(?: the)? type $expectedType/"); |
48
|
|
|
|
49
|
|
|
StreamConnection::createTcp(StreamConnection::DEFAULT_TCP_URI, [$optionName => $optionValue]); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @dataProvider \Tarantool\Client\Tests\Unit\OptionsProvider::provideConnectionArrayOptionsOfInvalidTypes |
54
|
|
|
*/ |
55
|
|
|
public function testCreateUdsRejectsOptionOfInvalidType(string $optionName, $optionValue, string $expectedType) : void |
56
|
|
|
{ |
57
|
|
|
$this->expectException(\TypeError::class); |
58
|
|
|
$this->expectExceptionMessageMatches("/must be of(?: the)? type $expectedType/"); |
59
|
|
|
|
60
|
|
|
StreamConnection::createUds('unix:///socket.sock', [$optionName => $optionValue]); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|