@@ -13,7 +13,10 @@ class FactoryTest extends TestCase
1313 private $ resolver ;
1414 private $ factory ;
1515
16- public function setUp ()
16+ /**
17+ * @before
18+ */
19+ public function setUpFactory ()
1720 {
1821 $ this ->loop = \React \EventLoop \Factory::create ();
1922 $ this ->resolver = $ this ->createResolverMock ();
@@ -31,7 +34,7 @@ public function testCreateClient()
3134
3235 $ this ->assertEquals ('127.0.0.1:12345 ' , $ capturedClient ->getRemoteAddress ());
3336
34- $ this ->assertContains ('127.0.0.1: ' , $ capturedClient ->getLocalAddress ());
37+ $ this ->assertContainsString ('127.0.0.1: ' , $ capturedClient ->getLocalAddress ());
3538 $ this ->assertNotEquals ('127.0.0.1:12345 ' , $ capturedClient ->getLocalAddress ());
3639
3740 $ capturedClient ->close ();
@@ -50,7 +53,7 @@ public function testCreateClientLocalhost()
5053
5154 $ this ->assertEquals ('127.0.0.1:12345 ' , $ capturedClient ->getRemoteAddress ());
5255
53- $ this ->assertContains ('127.0.0.1: ' , $ capturedClient ->getLocalAddress ());
56+ $ this ->assertContainsString ('127.0.0.1: ' , $ capturedClient ->getLocalAddress ());
5457 $ this ->assertNotEquals ('127.0.0.1:12345 ' , $ capturedClient ->getLocalAddress ());
5558
5659 $ capturedClient ->close ();
@@ -83,7 +86,7 @@ public function testCreateClientIpv6()
8386
8487 $ this ->assertEquals ('[::1]:12345 ' , $ capturedClient ->getRemoteAddress ());
8588
86- $ this ->assertContains ('[::1]: ' , $ capturedClient ->getLocalAddress ());
89+ $ this ->assertContainsString ('[::1]: ' , $ capturedClient ->getLocalAddress ());
8790 $ this ->assertNotEquals ('[::1]:12345 ' , $ capturedClient ->getLocalAddress ());
8891
8992 $ capturedClient ->close ();
@@ -133,37 +136,26 @@ public function testCreateClientWithHostnameWillUseResolver()
133136 $ client ->close ();
134137 }
135138
136- /**
137- * @expectedException RuntimeException
138- */
139139 public function testCreateClientWithHostnameWillRejectIfResolverRejects ()
140140 {
141141 $ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ('example.com ' )->willReturn (Promise \reject (new \RuntimeException ('test ' )));
142142
143+ $ this ->setExpectedException ('RuntimeException ' );
143144 Block \await ($ this ->factory ->createClient ('example.com:0 ' ), $ this ->loop );
144145 }
145146
146- /**
147- * @expectedException Exception
148- * @expectedExceptionMessage Unable to create client socket
149- */
150147 public function testCreateClientWithInvalidHostnameWillReject ()
151148 {
149+ $ this ->setExpectedException ('Exception ' , 'Unable to create client socket ' );
152150 Block \await ($ this ->factory ->createClient ('///// ' ), $ this ->loop );
153151 }
154152
155- /**
156- * @expectedException Exception
157- * @expectedExceptionMessage Unable to create server socket
158- */
159153 public function testCreateServerWithInvalidHostnameWillReject ()
160154 {
155+ $ this ->setExpectedException ('Exception ' , 'Unable to create server socket ' );
161156 Block \await ($ this ->factory ->createServer ('///// ' ), $ this ->loop );
162157 }
163158
164- /**
165- * @expectedException RuntimeException
166- */
167159 public function testCancelCreateClientWithCancellableHostnameResolver ()
168160 {
169161 $ promise = new Promise \Promise (function () { }, $ this ->expectCallableOnce ());
@@ -172,12 +164,10 @@ public function testCancelCreateClientWithCancellableHostnameResolver()
172164 $ promise = $ this ->factory ->createClient ('example.com:0 ' );
173165 $ promise ->cancel ();
174166
167+ $ this ->setExpectedException ('RuntimeException ' );
175168 Block \await ($ promise , $ this ->loop );
176169 }
177170
178- /**
179- * @expectedException RuntimeException
180- */
181171 public function testCancelCreateClientWithUncancellableHostnameResolver ()
182172 {
183173 $ promise = $ this ->getMockBuilder ('React\Promise\PromiseInterface ' )->getMock ();
@@ -186,6 +176,7 @@ public function testCancelCreateClientWithUncancellableHostnameResolver()
186176 $ promise = $ this ->factory ->createClient ('example.com:0 ' );
187177 $ promise ->cancel ();
188178
179+ $ this ->setExpectedException ('RuntimeException ' );
189180 Block \await ($ promise , $ this ->loop );
190181 }
191182}
0 commit comments