This repository was archived by the owner on Jul 7, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
tests/TestCase/Wrapper/CakePHP/V2 Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,18 @@ public function getDatasource()
63
63
return 'Database/ ' . ucfirst ($ engine );
64
64
}
65
65
66
+ /**
67
+ * getPersistent
68
+ *
69
+ * Cast the string value in the dsn to a bool
70
+ *
71
+ * @return bool
72
+ */
73
+ public function getPersistent ()
74
+ {
75
+ return (bool )$ this ->dsn ->persistent ;
76
+ }
77
+
66
78
/**
67
79
* parse a url as a database dsn
68
80
*
Original file line number Diff line number Diff line change @@ -30,6 +30,42 @@ public function testDefaults($url, $expected)
30
30
$ this ->assertSame ($ url , $ return , 'The dsn should parse back to the same url ' );
31
31
}
32
32
33
+ /**
34
+ * testPersistentCasting
35
+ *
36
+ * Persistent need to be a bool otherwise PDO may ignore the value
37
+ *
38
+ * @return void
39
+ */
40
+ public function testPersistentCasting () {
41
+ $ string = "mysql://root:password@localhost/dbname?persistent=0 " ;
42
+ $ expected = [
43
+ 'datasource ' => 'Database/Mysql ' ,
44
+ 'host ' => 'localhost ' ,
45
+ 'port ' => 3306 ,
46
+ 'login ' => 'root ' ,
47
+ 'password ' => 'password ' ,
48
+ 'database ' => 'dbname ' ,
49
+ 'persistent ' => false
50
+ ];
51
+ $ result = DbDsn::parse ($ string );
52
+ $ this ->assertSame ($ expected , $ result );
53
+
54
+ $ string = "mysql://root:password@localhost/dbname?persistent=1 " ;
55
+ $ expected = [
56
+ 'datasource ' => 'Database/Mysql ' ,
57
+ 'host ' => 'localhost ' ,
58
+ 'port ' => 3306 ,
59
+ 'login ' => 'root ' ,
60
+ 'password ' => 'password ' ,
61
+ 'database ' => 'dbname ' ,
62
+ 'persistent ' => true
63
+ ];
64
+ $ result = DbDsn::parse ($ string );
65
+ $ this ->assertSame ($ expected , $ result );
66
+
67
+ }
68
+
33
69
/**
34
70
* defaultsProvider
35
71
*
You can’t perform that action at this time.
0 commit comments