2
2
3
3
namespace React \Tests \Dns ;
4
4
5
- use React \EventLoop \Factory as LoopFactory ;
6
5
use React \Dns \Resolver \Factory ;
7
- use React \Dns \RecordNotFoundException ;
8
6
use React \Dns \Model \Message ;
7
+ use React \EventLoop \Loop ;
9
8
10
9
class FunctionalResolverTest extends TestCase
11
10
{
12
- private $ loop ;
13
11
private $ resolver ;
14
12
15
13
/**
16
14
* @before
17
15
*/
18
16
public function setUpResolver ()
19
17
{
20
- $ this ->loop = LoopFactory::create ();
21
-
22
18
$ factory = new Factory ();
23
- $ this ->resolver = $ factory ->create ('8.8.8.8 ' , $ this -> loop );
19
+ $ this ->resolver = $ factory ->create ('8.8.8.8 ' );
24
20
}
25
21
26
22
public function testResolveLocalhostResolves ()
27
23
{
28
24
$ promise = $ this ->resolver ->resolve ('localhost ' );
29
25
$ promise ->then ($ this ->expectCallableOnce (), $ this ->expectCallableNever ());
30
26
31
- $ this -> loop -> run ();
27
+ Loop:: run ();
32
28
}
33
29
34
30
public function testResolveAllLocalhostResolvesWithArray ()
35
31
{
36
32
$ promise = $ this ->resolver ->resolveAll ('localhost ' , Message::TYPE_A );
37
33
$ promise ->then ($ this ->expectCallableOnceWith ($ this ->isType ('array ' )), $ this ->expectCallableNever ());
38
34
39
- $ this -> loop -> run ();
35
+ Loop:: run ();
40
36
}
41
37
42
38
/**
@@ -47,35 +43,35 @@ public function testResolveGoogleResolves()
47
43
$ promise = $ this ->resolver ->resolve ('google.com ' );
48
44
$ promise ->then ($ this ->expectCallableOnce (), $ this ->expectCallableNever ());
49
45
50
- $ this -> loop -> run ();
46
+ Loop:: run ();
51
47
}
52
48
53
49
/**
54
50
* @group internet
55
51
*/
56
52
public function testResolveGoogleOverUdpResolves ()
57
53
{
58
- $ factory = new Factory ($ this -> loop );
59
- $ this ->resolver = $ factory ->create ('udp://8.8.8.8 ' , $ this -> loop );
54
+ $ factory = new Factory ();
55
+ $ this ->resolver = $ factory ->create ('udp://8.8.8.8 ' );
60
56
61
57
$ promise = $ this ->resolver ->resolve ('google.com ' );
62
58
$ promise ->then ($ this ->expectCallableOnce (), $ this ->expectCallableNever ());
63
59
64
- $ this -> loop -> run ();
60
+ Loop:: run ();
65
61
}
66
62
67
63
/**
68
64
* @group internet
69
65
*/
70
66
public function testResolveGoogleOverTcpResolves ()
71
67
{
72
- $ factory = new Factory ($ this -> loop );
73
- $ this ->resolver = $ factory ->create ('tcp://8.8.8.8 ' , $ this -> loop );
68
+ $ factory = new Factory ();
69
+ $ this ->resolver = $ factory ->create ('tcp://8.8.8.8 ' );
74
70
75
71
$ promise = $ this ->resolver ->resolve ('google.com ' );
76
72
$ promise ->then ($ this ->expectCallableOnce (), $ this ->expectCallableNever ());
77
73
78
- $ this -> loop -> run ();
74
+ Loop:: run ();
79
75
}
80
76
81
77
/**
@@ -84,25 +80,25 @@ public function testResolveGoogleOverTcpResolves()
84
80
public function testResolveAllGoogleMxResolvesWithCache ()
85
81
{
86
82
$ factory = new Factory ();
87
- $ this ->resolver = $ factory ->createCached ('8.8.8.8 ' , $ this -> loop );
83
+ $ this ->resolver = $ factory ->createCached ('8.8.8.8 ' );
88
84
89
85
$ promise = $ this ->resolver ->resolveAll ('google.com ' , Message::TYPE_MX );
90
86
$ promise ->then ($ this ->expectCallableOnceWith ($ this ->isType ('array ' )), $ this ->expectCallableNever ());
91
87
92
- $ this -> loop -> run ();
88
+ Loop:: run ();
93
89
}
94
90
/**
95
91
* @group internet
96
92
*/
97
93
public function testResolveAllGoogleCaaResolvesWithCache ()
98
94
{
99
95
$ factory = new Factory ();
100
- $ this ->resolver = $ factory ->createCached ('8.8.8.8 ' , $ this -> loop );
96
+ $ this ->resolver = $ factory ->createCached ('8.8.8.8 ' );
101
97
102
98
$ promise = $ this ->resolver ->resolveAll ('google.com ' , Message::TYPE_CAA );
103
99
$ promise ->then ($ this ->expectCallableOnceWith ($ this ->isType ('array ' )), $ this ->expectCallableNever ());
104
100
105
- $ this -> loop -> run ();
101
+ Loop:: run ();
106
102
}
107
103
108
104
/**
@@ -112,7 +108,7 @@ public function testResolveInvalidRejects()
112
108
{
113
109
$ promise = $ this ->resolver ->resolve ('example.invalid ' );
114
110
115
- $ this -> loop -> run ();
111
+ Loop:: run ();
116
112
117
113
$ exception = null ;
118
114
$ promise ->then (null , function ($ reason ) use (&$ exception ) {
@@ -134,7 +130,7 @@ public function testResolveCancelledRejectsImmediately()
134
130
$ promise ->cancel ();
135
131
136
132
$ time = microtime (true );
137
- $ this -> loop -> run ();
133
+ Loop:: run ();
138
134
$ time = microtime (true ) - $ time ;
139
135
140
136
$ this ->assertLessThan (0.1 , $ time );
@@ -156,7 +152,7 @@ public function testResolveAllInvalidTypeRejects()
156
152
{
157
153
$ promise = $ this ->resolver ->resolveAll ('google.com ' , Message::TYPE_PTR );
158
154
159
- $ this -> loop -> run ();
155
+ Loop:: run ();
160
156
161
157
$ exception = null ;
162
158
$ promise ->then (null , function ($ reason ) use (&$ exception ) {
@@ -172,7 +168,7 @@ public function testResolveAllInvalidTypeRejects()
172
168
public function testInvalidResolverDoesNotResolveGoogle ()
173
169
{
174
170
$ factory = new Factory ();
175
- $ this ->resolver = $ factory ->create ('255.255.255.255 ' , $ this -> loop );
171
+ $ this ->resolver = $ factory ->create ('255.255.255.255 ' );
176
172
177
173
$ promise = $ this ->resolver ->resolve ('google.com ' );
178
174
$ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableOnce ());
@@ -185,7 +181,7 @@ public function testResolveShouldNotCauseGarbageReferencesWhenUsingInvalidNamese
185
181
}
186
182
187
183
$ factory = new Factory ();
188
- $ this ->resolver = $ factory ->create ('255.255.255.255 ' , $ this -> loop );
184
+ $ this ->resolver = $ factory ->create ('255.255.255.255 ' );
189
185
190
186
gc_collect_cycles ();
191
187
gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
@@ -203,7 +199,7 @@ public function testResolveCachedShouldNotCauseGarbageReferencesWhenUsingInvalid
203
199
}
204
200
205
201
$ factory = new Factory ();
206
- $ this ->resolver = $ factory ->createCached ('255.255.255.255 ' , $ this -> loop );
202
+ $ this ->resolver = $ factory ->createCached ('255.255.255.255 ' );
207
203
208
204
gc_collect_cycles ();
209
205
gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
@@ -221,7 +217,7 @@ public function testCancelResolveShouldNotCauseGarbageReferences()
221
217
}
222
218
223
219
$ factory = new Factory ();
224
- $ this ->resolver = $ factory ->create ('127.0.0.1 ' , $ this -> loop );
220
+ $ this ->resolver = $ factory ->create ('127.0.0.1 ' );
225
221
226
222
gc_collect_cycles ();
227
223
gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
@@ -240,7 +236,7 @@ public function testCancelResolveCachedShouldNotCauseGarbageReferences()
240
236
}
241
237
242
238
$ factory = new Factory ();
243
- $ this ->resolver = $ factory ->createCached ('127.0.0.1 ' , $ this -> loop );
239
+ $ this ->resolver = $ factory ->createCached ('127.0.0.1 ' );
244
240
245
241
gc_collect_cycles ();
246
242
gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
0 commit comments