|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kazuakim\Reddish; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* ClientsTest. |
|
7
|
|
|
* |
|
8
|
|
|
* @copyright KazuakiM <[email protected]> |
|
9
|
|
|
* @author KazuakiM <[email protected]> |
|
10
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License |
|
11
|
|
|
* |
|
12
|
|
|
* @link https://github.com/KazuakiM/reddish |
|
13
|
|
|
*/ |
|
14
|
|
|
class ClientsTest extends \PHPUnit\Framework\TestCase //{{{ |
|
|
|
|
|
|
15
|
|
|
{ |
|
16
|
|
|
// Class variable {{{ |
|
|
|
|
|
|
17
|
|
|
private static $_defaultConfig = [ |
|
18
|
|
|
// 'connect' paramater |
|
19
|
|
|
'host' => '127.0.0.1', //can be a host, or the path to a unix domain socket |
|
20
|
|
|
'port' => 6379, |
|
21
|
|
|
'timeout' => 1.0, //value in seconds (optional, default is 0 meaning unlimited) |
|
22
|
|
|
'reserved' => null, //should be NULL if retry_interval is specified |
|
23
|
|
|
'retry_interval' => null, //value in milliseconds |
|
24
|
|
|
'read_timeout' => 1.0, //value in seconds (optional, default is 0 meaning unlimited) |
|
25
|
|
|
|
|
26
|
|
|
// 'pconnect' paramater |
|
27
|
|
|
'persistent_id' => '', //identity for the requested persistent connection |
|
28
|
|
|
|
|
29
|
|
|
// 'auth' paramater |
|
30
|
|
|
'password' => null, |
|
31
|
|
|
|
|
32
|
|
|
// serializer |
|
33
|
|
|
'serializer' => \Redis::SERIALIZER_NONE, |
|
34
|
|
|
|
|
35
|
|
|
// 'connect' or 'pconnect' |
|
|
|
|
|
|
36
|
|
|
'persistent' => false, //default is connect |
|
37
|
|
|
]; |
|
38
|
|
|
//}}} |
|
39
|
|
|
|
|
40
|
|
|
protected function setUp() //{{{ |
|
41
|
|
|
{ |
|
42
|
|
|
} //}}} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @expectedException \Kazuakim\Reddish\ReddishException |
|
46
|
|
|
* @expectedExceptionCode 0 |
|
47
|
|
|
* @expectedExceptionMessage connect errored. |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testConnectionPersistentError() //{{{ |
|
50
|
|
|
{ |
|
51
|
|
|
$config = self::$_defaultConfig; |
|
52
|
|
|
$config['host'] = '127.0.0.2'; |
|
53
|
|
|
$clients = new Clients($config); |
|
|
|
|
|
|
54
|
|
|
} //}}} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @expectedException \Kazuakim\Reddish\ReddishException |
|
58
|
|
|
* @expectedExceptionCode 0 |
|
59
|
|
|
* @expectedExceptionMessage pconnect errored. |
|
60
|
|
|
*/ |
|
61
|
|
|
public function testConnectionError() //{{{ |
|
62
|
|
|
{ |
|
63
|
|
|
$config = self::$_defaultConfig; |
|
64
|
|
|
$config['host'] = '127.0.0.2'; |
|
65
|
|
|
$config['persistent'] = true; |
|
66
|
|
|
$clients = new Clients($config); |
|
|
|
|
|
|
67
|
|
|
} //}}} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @expectedException \Kazuakim\Reddish\ReddishException |
|
71
|
|
|
* @expectedExceptionCode 0 |
|
72
|
|
|
* @expectedExceptionMessage Connection closed |
|
73
|
|
|
*/ |
|
74
|
|
|
public function testPingError() //{{{ |
|
75
|
|
|
{ |
|
76
|
|
|
$config = self::$_defaultConfig; |
|
77
|
|
|
$config['persistent'] = true; |
|
78
|
|
|
$clients = new Clients($config); |
|
79
|
|
|
$clients->close(); |
|
80
|
|
|
$clients->ping(); |
|
81
|
|
|
} //}}} |
|
82
|
|
|
|
|
83
|
|
|
public function testConnection() //{{{ |
|
84
|
|
|
{ |
|
85
|
|
|
$config = self::$_defaultConfig; |
|
86
|
|
|
$clients = new Clients($config); |
|
87
|
|
|
$this->assertTrue($clients->isConnected()); |
|
|
|
|
|
|
88
|
|
|
unset($clients); |
|
89
|
|
|
|
|
90
|
|
|
$config['persistent'] = true; |
|
91
|
|
|
$clients = new Clients($config); |
|
92
|
|
|
$this->assertTrue($clients->isConnected()); |
|
93
|
|
|
$clients->ping(); |
|
94
|
|
|
$clients->close(); |
|
95
|
|
|
unset($clients); |
|
96
|
|
|
} //}}} |
|
97
|
|
|
|
|
98
|
|
|
public function testSave() //{{{ |
|
99
|
|
|
{ |
|
100
|
|
|
$config = self::$_defaultConfig; |
|
101
|
|
|
$clients = new Clients($config); |
|
102
|
|
|
$clients->set('key', 1); |
|
103
|
|
|
$this->assertSame('1', $clients->get('key')); |
|
104
|
|
|
} //}}} |
|
105
|
|
|
} //}}} |
|
106
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths