forked from php-amqplib/php-amqplib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AMQPStreamConnectionTest.php
113 lines (102 loc) · 3.21 KB
/
AMQPStreamConnectionTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace PhpAmqpLib\Tests\Unit\Connection;
use InvalidArgumentException;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PHPUnit\Framework\TestCase;
use RuntimeException;
class AMQPStreamConnectionTest extends TestCase
{
/**
* @test
*/
public function channel_rpc_timeout_should_be_invalid_if_greater_than_read_write_timeout(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('channel RPC timeout must not be greater than I/O read-write timeout');
new AMQPStreamConnection(
HOST,
PORT,
USER,
PASS,
VHOST,
false,
'AMQPLAIN',
null,
'en_US',
3.0,
3.0,
null,
false,
0,
5.0
);
}
/**
* @test
* Generate deprecation warning if ssl_protocol is set
*/
public function trigger_deprecation_is_ssl_protocl_set(): void
{
// this is a workaround for deprecated PHPUnit functions
set_error_handler(
static function ($errno, $errstr) {
restore_error_handler();
throw new RuntimeException($errstr, $errno);
},
E_USER_DEPRECATED
);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage(
'$ssl_protocol parameter is deprecated, use stream_context_set_option($context, \'ssl\', \'crypto_method\', $ssl_protocol) instead (see https://www.php.net/manual/en/function.stream-socket-enable-crypto.php for possible values)'
);
new AMQPStreamConnection(
HOST,
PORT,
USER,
PASS,
VHOST,
false,
'AMQPLAIN',
null,
'en_US',
3.0,
3.0,
null,
false,
0,
3.0,
'test_ssl_protocol'
);
}
/**
* @test
* Generate deprecation warning if ssl_protocol is set with named parameters
*/
public function trigger_deprecation_is_ssl_protocl_set_with_named_params(): void
{
if (PHP_VERSION_ID < 80000) {
$this->markTestSkipped('Named parameters are available in PHP 8.0+');
}
// this is a workaround for deprecated PHPUnit functions
set_error_handler(
static function ($errno, $errstr) {
restore_error_handler();
throw new RuntimeException($errstr, $errno);
},
E_USER_DEPRECATED
);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage(
'$ssl_protocol parameter is deprecated, use stream_context_set_option($context, \'ssl\', \'crypto_method\', $ssl_protocol) instead (see https://www.php.net/manual/en/function.stream-socket-enable-crypto.php for possible values)'
);
new AMQPStreamConnection(
host: HOST,
port: PORT,
user: USER,
password: PASS,
vhost: VHOST,
channel_rpc_timeout: 3.0,
ssl_protocol: 'test_ssl_protocol'
);
}
}