@@ -30,7 +30,7 @@ public function testConnectWillUseHostAndDefaultPort()
30
30
$ connector ->expects ($ this ->once ())->method ('connect ' )->with ('127.0.0.1:3306 ' )->willReturn ($ pending );
31
31
32
32
$ factory = new Factory ($ loop , $ connector );
33
- $ factory ->createConnection ('127.0.0.1 ' );
33
+ $ factory ->createConnection ('mysql:// 127.0.0.1 ' );
34
34
}
35
35
36
36
public function testConnectWillUseGivenScheme ()
@@ -44,28 +44,6 @@ public function testConnectWillUseGivenScheme()
44
44
$ factory ->createConnection ('mysql://127.0.0.1 ' );
45
45
}
46
46
47
- public function testConnectWillRejectWhenGivenInvalidScheme ()
48
- {
49
- $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
50
- $ connector = $ this ->getMockBuilder ('React\Socket\ConnectorInterface ' )->getMock ();
51
-
52
- $ factory = new Factory ($ loop , $ connector );
53
-
54
- $ promise = $ factory ->createConnection ('foo://127.0.0.1 ' );
55
-
56
- $ promise ->then (null , $ this ->expectCallableOnceWith (
57
- $ this ->logicalAnd (
58
- $ this ->isInstanceOf ('InvalidArgumentException ' ),
59
- $ this ->callback (function (\InvalidArgumentException $ e ) {
60
- return $ e ->getMessage () === 'Invalid MySQL URI given (EINVAL) ' ;
61
- }),
62
- $ this ->callback (function (\InvalidArgumentException $ e ) {
63
- return $ e ->getCode () === (defined ('SOCKET_EINVAL ' ) ? SOCKET_EINVAL : 22 );
64
- })
65
- )
66
- ));
67
- }
68
-
69
47
public function testConnectWillUseGivenHostAndGivenPort ()
70
48
{
71
49
$ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
@@ -74,7 +52,7 @@ public function testConnectWillUseGivenHostAndGivenPort()
74
52
$ connector ->expects ($ this ->once ())->method ('connect ' )->with ('127.0.0.1:1234 ' )->willReturn ($ pending );
75
53
76
54
$ factory = new Factory ($ loop , $ connector );
77
- $ factory ->createConnection ('127.0.0.1:1234 ' );
55
+ $ factory ->createConnection ('mysql:// 127.0.0.1:1234 ' );
78
56
}
79
57
80
58
public function testConnectWillUseGivenUserInfoAsDatabaseCredentialsAfterUrldecoding ()
@@ -87,7 +65,7 @@ public function testConnectWillUseGivenUserInfoAsDatabaseCredentialsAfterUrldeco
87
65
$ connector ->expects ($ this ->once ())->method ('connect ' )->with ('127.0.0.1:3306 ' )->willReturn (\React \Promise \resolve ($ connection ));
88
66
89
67
$ factory = new Factory ($ loop , $ connector );
90
- $ promise =
$ factory->
createConnection (
'user%[email protected] ' );
68
+ $ promise =
$ factory->
createConnection (
'mysql:// user%[email protected] ' );
91
69
92
70
$ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
93
71
@@ -104,48 +82,13 @@ public function testConnectWillUseGivenPathAsDatabaseNameAfterUrldecoding()
104
82
$ connector ->expects ($ this ->once ())->method ('connect ' )->with ('127.0.0.1:3306 ' )->willReturn (\React \Promise \resolve ($ connection ));
105
83
106
84
$ factory = new Factory ($ loop , $ connector );
107
- $ promise = $ factory ->createConnection ('127.0.0.1/test%20database ' );
85
+ $ promise = $ factory ->createConnection ('mysql:// 127.0.0.1/test%20database ' );
108
86
109
87
$ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
110
88
111
89
$ connection ->emit ('data ' , ["\x33\0\0\0" . "\x0a" . "mysql \0" . str_repeat ("\0" , 44 )]);
112
90
}
113
91
114
- public function testConnectWithInvalidUriWillRejectWithoutConnecting ()
115
- {
116
- $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
117
- $ connector = $ this ->getMockBuilder ('React\Socket\ConnectorInterface ' )->getMock ();
118
- $ connector ->expects ($ this ->never ())->method ('connect ' );
119
-
120
- $ factory = new Factory ($ loop , $ connector );
121
- $ promise = $ factory ->createConnection ('/// ' );
122
-
123
- $ promise ->then (null , $ this ->expectCallableOnceWith (
124
- $ this ->logicalAnd (
125
- $ this ->isInstanceOf ('InvalidArgumentException ' ),
126
- $ this ->callback (function (\InvalidArgumentException $ e ) {
127
- return $ e ->getMessage () === 'Invalid MySQL URI given (EINVAL) ' ;
128
- }),
129
- $ this ->callback (function (\InvalidArgumentException $ e ) {
130
- return $ e ->getCode () === (defined ('SOCKET_EINVAL ' ) ? SOCKET_EINVAL : 22 );
131
- })
132
- )
133
- ));
134
- }
135
-
136
- public function testConnectWithInvalidCharsetWillRejectWithoutConnecting ()
137
- {
138
- $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
139
- $ connector = $ this ->getMockBuilder ('React\Socket\ConnectorInterface ' )->getMock ();
140
- $ connector ->expects ($ this ->never ())->method ('connect ' );
141
-
142
- $ factory = new Factory ($ loop , $ connector );
143
- $ promise = $ factory ->createConnection ('localhost?charset=unknown ' );
144
-
145
- $ this ->assertInstanceof ('React\Promise\PromiseInterface ' , $ promise );
146
- $ promise ->then (null , $ this ->expectCallableOnce ());
147
- }
148
-
149
92
public function testConnectWithInvalidHostRejectsWithConnectionError ()
150
93
{
151
94
$ factory = new Factory ();
@@ -204,7 +147,7 @@ public function testConnectWillRejectWhenServerClosesConnection()
204
147
$ this ->logicalAnd (
205
148
$ this ->isInstanceOf ('RuntimeException ' ),
206
149
$ this ->callback (function (\RuntimeException $ e ) use ($ uri ) {
207
- return $ e ->getMessage () === 'Connection to mysql:// ' . $ uri . ' failed during authentication: Connection closed by peer (ECONNRESET) ' ;
150
+ return $ e ->getMessage () === 'Connection to ' . $ uri . ' failed during authentication: Connection closed by peer (ECONNRESET) ' ;
208
151
}),
209
152
$ this ->callback (function (\RuntimeException $ e ) {
210
153
return $ e ->getCode () === (defined ('SOCKET_ECONNRESET ' ) ? SOCKET_ECONNRESET : 104 );
@@ -244,7 +187,7 @@ public function testConnectWillRejectOnDefaultTimeoutFromIniDespiteValidAuth()
244
187
{
245
188
$ factory = new Factory ();
246
189
247
- $ uri = ' mysql:// ' . $ this ->getConnectionString ();
190
+ $ uri = $ this ->getConnectionString ();
248
191
249
192
$ old = ini_get ('default_socket_timeout ' );
250
193
ini_set ('default_socket_timeout ' , '0 ' );
@@ -439,7 +382,7 @@ public function testlConnectWillRejectWhenUnderlyingConnectorRejects()
439
382
$ connector ->expects ($ this ->once ())->method ('connect ' )->willReturn (\React \Promise \reject (new \RuntimeException ('Failed ' , 123 )));
440
383
441
384
$ factory = new Factory ($ loop , $ connector );
442
- $ promise =
$ factory->
createConnection (
'user:[email protected] ' );
385
+ $ promise =
$ factory->
createConnection (
'mysql:// user:[email protected] ' );
443
386
444
387
$ promise ->then (null , $ this ->expectCallableOnceWith (
445
388
$ this ->logicalAnd (
@@ -457,10 +400,6 @@ public function testlConnectWillRejectWhenUnderlyingConnectorRejects()
457
400
public function provideUris ()
458
401
{
459
402
return [
460
- [
461
- 'localhost ' ,
462
- 'mysql://localhost '
463
- ],
464
403
[
465
404
'mysql://localhost ' ,
466
405
'mysql://localhost '
@@ -520,7 +459,7 @@ public function testCancelConnectWillCancelPendingConnectionWithRuntimeException
520
459
$ connector ->expects ($ this ->once ())->method ('connect ' )->willReturn ($ pending );
521
460
522
461
$ factory = new Factory ($ loop , $ connector );
523
- $ promise = $ factory ->createConnection ('127.0.0.1 ' );
462
+ $ promise = $ factory ->createConnection ('mysql:// 127.0.0.1 ' );
524
463
525
464
$ promise ->cancel ();
526
465
@@ -547,7 +486,7 @@ public function testCancelConnectDuringAuthenticationWillCloseConnection()
547
486
$ connector ->expects ($ this ->once ())->method ('connect ' )->willReturn (\React \Promise \resolve ($ connection ));
548
487
549
488
$ factory = new Factory ($ loop , $ connector );
550
- $ promise = $ factory ->createConnection ('127.0.0.1 ' );
489
+ $ promise = $ factory ->createConnection ('mysql:// 127.0.0.1 ' );
551
490
552
491
$ promise ->cancel ();
553
492
0 commit comments