@@ -78,6 +78,17 @@ public function testGetConnection()
7878 $ this ->assertInstanceOf (\PDO ::class, DB ::getConnection ('mysql ' ));
7979 }
8080
81+ /**
82+ * @covers Divergence\IO\Database\MySQL::setConnection
83+ */
84+ public function testSetConnection ()
85+ {
86+ TestUtils::requireDB ($ this );
87+ DB ::setConnection ('tests-mysql-socket ' );
88+ $ this ->assertEquals ('tests-mysql-socket ' ,DB ::$ currentConnection );
89+ DB ::setConnection ('tests-mysql ' );
90+ }
91+
8192 /**
8293 * @covers Divergence\IO\Database\MySQL::escape
8394 *
@@ -96,7 +107,7 @@ public function testEscape()
96107
97108 $ littleBobbyTables = 'Robert \'); DROP TABLE Students;-- ' ;
98109 $ safeLittleBobbyTables = $ z ($ littleBobbyTables );
99-
110+
100111 $ arrayOfBobbies = [
101112 'lorum ipsum ' ,
102113 $ littleBobbyTables ,
@@ -107,7 +118,7 @@ public function testEscape()
107118 foreach ($ arrayOfBobbies as $ oneBob ) {
108119 $ safeArrayOfBobbies [] = $ z ($ oneBob );
109120 }
110-
121+
111122 $ this ->assertEquals ($ safeLittleBobbyTables , DB ::escape ($ littleBobbyTables ));
112123 $ this ->assertEquals ($ safeArrayOfBobbies , DB ::escape ($ arrayOfBobbies ));
113124 $ this ->assertEquals (new \stdClass (), DB ::escape (new \stdClass ()));
@@ -126,7 +137,7 @@ public function testAffectedRows()
126137
127138 $ this ->assertEquals (2 , DB ::affectedRows ());
128139 }
129-
140+
130141 /**
131142 * @covers Divergence\IO\Database\MySQL::foundRows
132143 * @covers Divergence\IO\Database\MySQL::oneValue
@@ -139,7 +150,7 @@ public function testFoundRows()
139150 $ tags = DB ::allRecords ('select SQL_CALC_FOUND_ROWS * from `tags` LIMIT 1; ' );
140151 $ foundRows = DB ::oneValue ('SELECT FOUND_ROWS() ' );
141152 $ tagsCount = DB ::oneValue ('SELECT COUNT(*) as `Count` FROM `tags` ' );
142-
153+
143154 $ this ->assertEquals ($ tagsCount , $ foundRows );
144155 $ this ->assertCount (1 , $ tags );
145156
@@ -149,7 +160,7 @@ public function testFoundRows()
149160 // valid query. no records found
150161 $ this ->assertFalse (DB ::oneValue ('SELECT * FROM `tags` WHERE 1=0 ' ));
151162 }
152-
163+
153164 /**
154165 * @covers Divergence\IO\Database\MySQL::insertID
155166 * @covers Divergence\IO\Database\MySQL::oneRecord
@@ -335,7 +346,7 @@ public function testNonQueryExceptionDevException()
335346 public function testNonQueryHandledException ()
336347 {
337348 TestUtils::requireDB ($ this );
338-
349+
339350 $ Context = $ this ;
340351 // another bad query but this time we handle the problem
341352 DB ::nonQuery ('UPDATE `%s` SET fake`=%d WHERE `ID`=%d ' , [
@@ -366,7 +377,7 @@ public function testAllRecords()
366377 TestUtils::requireDB ($ this );
367378
368379 $ tables = DB ::allRecords ('SHOW TABLES ' );
369-
380+
370381 $ this ->assertCount (9 , $ tables );
371382 foreach ($ tables as $ table ) {
372383 $ this ->assertNotEmpty ($ table ['Tables_in_test ' ]);
@@ -409,7 +420,7 @@ public function testClearCachedRecord()
409420 'Tag ' ,
410421 'Linux ' ,
411422 ];
412-
423+
413424 $ key = sprintf ('%s/%s:%s ' , Tag::$ tableName , 'Tag ' , 'Linux ' );
414425 $ record = testableDB::oneRecordCached ($ key , $ query , $ params );
415426 $ cache = testableDB::getProtected ('_record_cache ' );
@@ -418,7 +429,7 @@ public function testClearCachedRecord()
418429 $ cache = testableDB::getProtected ('_record_cache ' );
419430 $ this ->assertNull ($ cache [$ key ]);
420431 }
421-
432+
422433 /**
423434 * @covers Divergence\IO\Database\MySQL::oneRecordCached
424435 *
@@ -433,7 +444,7 @@ public function testOneRecordCached()
433444 'Tag ' ,
434445 'Linux ' ,
435446 ];
436-
447+
437448 $ key = sprintf ('%s/%s:%s ' , Tag::$ tableName , 'Tag ' , 'Linux ' );
438449 $ record = testableDB::oneRecordCached ($ key , $ query , $ params );
439450 $ cache = testableDB::getProtected ('_record_cache ' );
@@ -504,7 +515,7 @@ public function testFinishQueryLog()
504515 $ result ->num_rows = 5 ;
505516
506517 testableDB::_finishQueryLog ($ x , $ result );
507-
518+
508519 $ expected_time_duration_ms = ($ x ['time_finish ' ] - $ x ['time_start ' ]) * 1000 ;
509520
510521 $ this ->assertEquals ('SELECT corgies ' , $ x ['query ' ]);
@@ -539,7 +550,7 @@ public function testConfig()
539550 public function testGetDefaultLabel ()
540551 {
541552 TestUtils::requireDB ($ this );
542-
553+
543554 $ this ->assertEquals (testableDB::$ defaultProductionLabel , testableDB::_getDefaultLabel ());
544555 App::$ Config ['environment ' ] = 'dev ' ;
545556 $ this ->assertEquals (testableDB::$ defaultDevLabel , testableDB::_getDefaultLabel ());
0 commit comments