File tree Expand file tree Collapse file tree 6 files changed +53
-3
lines changed Expand file tree Collapse file tree 6 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -218,9 +218,7 @@ private function connect()
218
218
),
219
219
$ connectionData ->getUser (),
220
220
$ connectionData ->getPassword (),
221
- [
222
- \PDO ::ATTR_PERSISTENT => true ,
223
- ]
221
+ [\PDO ::ATTR_PERSISTENT => true ] + $ connectionData ->getDriverOptions ()
224
222
);
225
223
}
226
224
Original file line number Diff line number Diff line change @@ -80,4 +80,12 @@ public function getPassword()
80
80
{
81
81
return $ this ->connectionData ['password ' ] ?? '' ;
82
82
}
83
+
84
+ /**
85
+ * @inheritDoc
86
+ */
87
+ public function getDriverOptions ()
88
+ {
89
+ return $ this ->connectionData ['driver_options ' ] ?? [];
90
+ }
83
91
}
Original file line number Diff line number Diff line change @@ -46,4 +46,11 @@ public function getUser();
46
46
* @return string|null
47
47
*/
48
48
public function getPassword ();
49
+
50
+ /**
51
+ * Returns driver options
52
+ *
53
+ * @return array
54
+ */
55
+ public function getDriverOptions ();
49
56
}
Original file line number Diff line number Diff line change @@ -68,4 +68,12 @@ public function getPassword()
68
68
{
69
69
return $ this ->connectionData ['password ' ] ?? '' ;
70
70
}
71
+
72
+ /**
73
+ * @inheritDoc
74
+ */
75
+ public function getDriverOptions ()
76
+ {
77
+ return $ this ->connectionData ['driver_options ' ] ?? [];
78
+ }
71
79
}
Original file line number Diff line number Diff line change @@ -23,13 +23,24 @@ public function testGetOptions()
23
23
'dbname ' => 'dbName ' ,
24
24
'username ' => 'user ' ,
25
25
'password ' => '1234 ' ,
26
+ 'driver_options ' => [
27
+ 'option1 ' => 'value1 ' ,
28
+ 'option2 ' => 'value2 '
29
+ ],
26
30
]);
27
31
28
32
$ this ->assertEquals ('127.0.0.1 ' , $ relationshipConnection ->getHost ());
29
33
$ this ->assertEquals ('3306 ' , $ relationshipConnection ->getPort ());
30
34
$ this ->assertEquals ('dbName ' , $ relationshipConnection ->getDbName ());
31
35
$ this ->assertEquals ('user ' , $ relationshipConnection ->getUser ());
32
36
$ this ->assertEquals ('1234 ' , $ relationshipConnection ->getPassword ());
37
+ $ this ->assertEquals (
38
+ [
39
+ 'option1 ' => 'value1 ' ,
40
+ 'option2 ' => 'value2 '
41
+ ],
42
+ $ relationshipConnection ->getDriverOptions ()
43
+ );
33
44
}
34
45
35
46
public function testGetOptionsWithEmptyPortAndPortInHost ()
@@ -75,4 +86,10 @@ public function testGetOptionsWithEmptyPortAndSocketHost()
75
86
$ this ->assertEquals ('/tmp/mysql.sock ' , $ relationshipConnection ->getHost ());
76
87
$ this ->assertEquals ('' , $ relationshipConnection ->getPort ());
77
88
}
89
+
90
+ public function testGetDriverOptionsEmpty ()
91
+ {
92
+ $ relationshipConnection = new Connection ([]);
93
+ $ this ->assertEquals ([], $ relationshipConnection ->getDriverOptions ());
94
+ }
78
95
}
Original file line number Diff line number Diff line change @@ -23,13 +23,24 @@ public function testGetOptions()
23
23
'path ' => 'dbName ' ,
24
24
'username ' => 'user ' ,
25
25
'password ' => '1234 ' ,
26
+ 'driver_options ' => [
27
+ 'option1 ' => 'value1 ' ,
28
+ 'option2 ' => 'value2 '
29
+ ],
26
30
]);
27
31
28
32
$ this ->assertEquals ('127.0.0.1 ' , $ relationshipConnection ->getHost ());
29
33
$ this ->assertEquals ('3306 ' , $ relationshipConnection ->getPort ());
30
34
$ this ->assertEquals ('dbName ' , $ relationshipConnection ->getDbName ());
31
35
$ this ->assertEquals ('user ' , $ relationshipConnection ->getUser ());
32
36
$ this ->assertEquals ('1234 ' , $ relationshipConnection ->getPassword ());
37
+ $ this ->assertEquals (
38
+ [
39
+ 'option1 ' => 'value1 ' ,
40
+ 'option2 ' => 'value2 '
41
+ ],
42
+ $ relationshipConnection ->getDriverOptions ()
43
+ );
33
44
}
34
45
35
46
public function testGetEmptyOptions ()
@@ -41,5 +52,6 @@ public function testGetEmptyOptions()
41
52
$ this ->assertEmpty ($ relationshipConnection ->getDbName ());
42
53
$ this ->assertEmpty ($ relationshipConnection ->getUser ());
43
54
$ this ->assertEmpty ($ relationshipConnection ->getPassword ());
55
+ $ this ->assertEquals ([], $ relationshipConnection ->getDriverOptions ());
44
56
}
45
57
}
You can’t perform that action at this time.
0 commit comments