22
33class ClientApiTest extends TestCase
44{
5- public function setUp (){
5+ public function setUp ()
6+ {
67 $ loop = React \EventLoop \Factory::create ();
78
89 $ dnsResolverFactory = new React \Dns \Resolver \Factory ();
@@ -12,6 +13,14 @@ public function setUp(){
1213
1314 $ this ->client = $ factory ->createClient ('127.0.0.1 ' , 9050 );
1415 }
16+
17+ /**
18+ * @expectedException InvalidArgumentException
19+ */
20+ public function testInvalidAuthInformation ()
21+ {
22+ $ this ->client ->setAuth (str_repeat ('a ' , 256 ), 'test ' );
23+ }
1524
1625 /**
1726 * @expectedException UnexpectedValueException
@@ -33,6 +42,24 @@ public function testValidAuthVersion()
3342 $ this ->client ->setAuth ('username ' , 'password ' );
3443 $ this ->assertNull ($ this ->client ->setProtocolVersion (5 ));
3544 }
45+
46+ /**
47+ * @expectedException UnexpectedValueException
48+ */
49+ public function testInvalidCanNotSetAuthenticationForSocks4 ()
50+ {
51+ $ this ->client ->setProtocolVersion (4 );
52+ $ this ->client ->setAuth ('username ' , 'password ' );
53+ }
54+
55+ public function testUnsetAuth ()
56+ {
57+ // unset auth even if it's not set is valid
58+ $ this ->client ->unsetAuth ();
59+
60+ $ this ->client ->setAuth ('username ' , 'password ' );
61+ $ this ->client ->unsetAuth ();
62+ }
3663
3764 /**
3865 * @dataProvider providerValidProtocolVersion
@@ -79,11 +106,23 @@ public function testInvalidResolveRemoteVersion()
79106 $ this ->client ->setResolveLocal (false );
80107 $ this ->client ->setProtocolVersion ('4 ' );
81108 }
109+
110+ public function testSetTimeout ()
111+ {
112+ $ this ->client ->setTimeout (1 );
113+ $ this ->client ->setTimeout (2.0 );
114+ $ this ->client ->setTimeout (3 );
115+ }
82116
83117 public function testCreateHttpClient ()
84118 {
85119 $ this ->assertInstanceOf ('\React\HttpClient\Client ' , $ this ->client ->createHttpClient ());
86120 }
121+
122+ public function testCreateConnector ()
123+ {
124+ $ this ->assertInstanceOf ('\React\SocketClient\ConnectorInterface ' , $ this ->client ->createConnector ());
125+ }
87126
88127 public function testCreateSecureConnector ()
89128 {
0 commit comments