11<?php
22
3+ namespace React \Tests \Datagram ;
4+
35use React \Datagram \Socket ;
46use React \Datagram \Factory ;
57use Clue \React \Block ;
@@ -13,7 +15,7 @@ class FactoryTest extends TestCase
1315
1416 public function setUp ()
1517 {
16- $ this ->loop = React \EventLoop \Factory::create ();
18+ $ this ->loop = \ React \EventLoop \Factory::create ();
1719 $ this ->resolver = $ this ->createResolverMock ();
1820 $ this ->factory = new Factory ($ this ->loop , $ this ->resolver );
1921 }
@@ -62,6 +64,8 @@ public function testCreateClientLocalhostWithDefaultResolver()
6264 $ promise = $ this ->factory ->createClient ('localhost:12345 ' );
6365
6466 $ capturedClient = Block \await ($ promise , $ this ->loop );
67+ $ this ->assertInstanceOf ('React\Datagram\SocketInterface ' , $ capturedClient );
68+
6569 $ capturedClient ->close ();
6670 }
6771
@@ -129,11 +133,13 @@ public function testCreateClientWithHostnameWillUseResolver()
129133 $ client ->close ();
130134 }
131135
136+ /**
137+ * @expectedException RuntimeException
138+ */
132139 public function testCreateClientWithHostnameWillRejectIfResolverRejects ()
133140 {
134141 $ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ('example.com ' )->willReturn (Promise \reject (new \RuntimeException ('test ' )));
135142
136- $ this ->setExpectedException ('RuntimeException ' );
137143 Block \await ($ this ->factory ->createClient ('example.com:0 ' ), $ this ->loop );
138144 }
139145
@@ -155,6 +161,9 @@ public function testCreateServerWithInvalidHostnameWillReject()
155161 Block \await ($ this ->factory ->createServer ('///// ' ), $ this ->loop );
156162 }
157163
164+ /**
165+ * @expectedException RuntimeException
166+ */
158167 public function testCancelCreateClientWithCancellableHostnameResolver ()
159168 {
160169 $ promise = new Promise \Promise (function () { }, $ this ->expectCallableOnce ());
@@ -163,10 +172,12 @@ public function testCancelCreateClientWithCancellableHostnameResolver()
163172 $ promise = $ this ->factory ->createClient ('example.com:0 ' );
164173 $ promise ->cancel ();
165174
166- $ this ->setExpectedException ('RuntimeException ' );
167175 Block \await ($ promise , $ this ->loop );
168176 }
169177
178+ /**
179+ * @expectedException RuntimeException
180+ */
170181 public function testCancelCreateClientWithUncancellableHostnameResolver ()
171182 {
172183 $ promise = $ this ->getMockBuilder ('React\Promise\PromiseInterface ' )->getMock ();
@@ -175,7 +186,6 @@ public function testCancelCreateClientWithUncancellableHostnameResolver()
175186 $ promise = $ this ->factory ->createClient ('example.com:0 ' );
176187 $ promise ->cancel ();
177188
178- $ this ->setExpectedException ('RuntimeException ' );
179189 Block \await ($ promise , $ this ->loop );
180190 }
181191}
0 commit comments