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
|
|
|
final class OptionsProvider |
17
|
|
|
{ |
18
|
|
|
public static function provideConnectionArrayOptionsOfValidTypes() : array |
19
|
|
|
{ |
20
|
|
|
return [ |
21
|
|
|
['connect_timeout', 42], |
22
|
|
|
['connect_timeout', 42.3], |
23
|
|
|
['socket_timeout', 42], |
24
|
|
|
['socket_timeout', 42.3], |
25
|
|
|
['persistent', false], |
26
|
|
|
]; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public static function provideConnectionArrayOptionsOfInvalidTypes() : array |
30
|
|
|
{ |
31
|
|
|
return [ |
32
|
|
|
['connect_timeout', '42.1', 'float'], |
33
|
|
|
['connect_timeout', false, 'float'], |
34
|
|
|
['socket_timeout', '42.2', 'float'], |
35
|
|
|
['socket_timeout', false, 'float'], |
36
|
|
|
['persistent', 0, 'bool'], |
37
|
|
|
['persistent', 'false', 'bool'], |
38
|
|
|
]; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function provideTcpExtraConnectionArrayOptionsOfValidTypes() : array |
42
|
|
|
{ |
43
|
|
|
return [ |
44
|
|
|
['tcp_nodelay', false], |
45
|
|
|
]; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public static function provideTcpExtraConnectionArrayOptionsOfInvalidTypes() : array |
49
|
|
|
{ |
50
|
|
|
return [ |
51
|
|
|
['tcp_nodelay', 0, 'bool'], |
52
|
|
|
['tcp_nodelay', 'false', 'bool'], |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public static function provideClientArrayOptionsOfValidTypes() : array |
57
|
|
|
{ |
58
|
|
|
return array_merge(self::provideConnectionArrayOptionsOfValidTypes(), [ |
59
|
|
|
['uri', 'foo'], |
60
|
|
|
['username', 'foo'], |
61
|
|
|
['password', 'bar', ['username' => 'foo']], |
62
|
|
|
['max_retries', 42], |
63
|
|
|
]); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public static function provideClientArrayOptionsOfInvalidTypes() : array |
67
|
|
|
{ |
68
|
|
|
return array_merge(self::provideConnectionArrayOptionsOfInvalidTypes(), [ |
69
|
|
|
['uri', 0, 'string'], |
70
|
|
|
['uri', false, 'string'], |
71
|
|
|
['username', 0, 'string'], |
72
|
|
|
['username', false, 'string'], |
73
|
|
|
['password', 0, 'string', ['username' => 'foobar']], |
74
|
|
|
['password', false, 'string', ['username' => 'foobar']], |
75
|
|
|
['max_retries', 4.2, 'int'], |
76
|
|
|
['max_retries', '42', 'int'], |
77
|
|
|
['max_retries', false, 'int'], |
78
|
|
|
]); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public static function provideClientDsnOptionsOfValidTypes() : array |
82
|
|
|
{ |
83
|
|
|
return [ |
84
|
|
|
['connect_timeout=42.4'], |
85
|
|
|
['socket_timeout=42.5'], |
86
|
|
|
['persistent=1'], |
87
|
|
|
['persistent=0'], |
88
|
|
|
['persistent=on'], |
89
|
|
|
['persistent=off'], |
90
|
|
|
['persistent=true'], |
91
|
|
|
['persistent=false'], |
92
|
|
|
['persistent=yes'], |
93
|
|
|
['persistent=no'], |
94
|
|
|
['tcp_nodelay=1'], |
95
|
|
|
['tcp_nodelay=0'], |
96
|
|
|
['tcp_nodelay=on'], |
97
|
|
|
['tcp_nodelay=off'], |
98
|
|
|
['tcp_nodelay=true'], |
99
|
|
|
['tcp_nodelay=false'], |
100
|
|
|
['tcp_nodelay=yes'], |
101
|
|
|
['tcp_nodelay=no'], |
102
|
|
|
['username=foo'], |
103
|
|
|
['username=foo&password=bar'], |
104
|
|
|
['max_retries=42'], |
105
|
|
|
]; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public static function provideClientDsnOptionsOfInvalidTypes() : array |
109
|
|
|
{ |
110
|
|
|
return [ |
111
|
|
|
['connect_timeout=foo', 'connect_timeout', 'float'], |
112
|
|
|
['socket_timeout=foo', 'socket_timeout', 'float'], |
113
|
|
|
['persistent=42.5', 'persistent', 'bool'], |
114
|
|
|
['persistent=foo', 'persistent', 'bool'], |
115
|
|
|
['tcp_nodelay=42.6', 'tcp_nodelay', 'bool'], |
116
|
|
|
['max_retries=foo', 'max_retries', 'int'], |
117
|
|
|
['max_retries=42.7', 'max_retries', 'int'], |
118
|
|
|
]; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|