@@ -368,7 +368,8 @@ public static function columnSqlProvider() {
368
368
* @return void
369
369
*/
370
370
public function testColumnSql ($ name , $ data , $ expected ) {
371
- $ schema = $ this ->_getMockedSchema ();
371
+ $ driver = $ this ->_getMockedDriver ();
372
+ $ schema = new MysqlSchema ($ driver );
372
373
373
374
$ table = (new Table ('articles ' ))->addColumn ($ name , $ data );
374
375
$ this ->assertEquals ($ expected , $ schema ->columnSql ($ table , $ name ));
@@ -380,7 +381,8 @@ public function testColumnSql($name, $data, $expected) {
380
381
* @return void
381
382
*/
382
383
public function testColumnSqlPrimaryKey () {
383
- $ schema = $ this ->_getMockedSchema ();
384
+ $ driver = $ this ->_getMockedDriver ();
385
+ $ schema = new MysqlSchema ($ driver );
384
386
385
387
$ table = new Table ('articles ' );
386
388
$ table ->addColumn ('id ' , [
@@ -429,22 +431,11 @@ public function testCreateTableSql() {
429
431
'columns ' => ['id ' ]
430
432
]);
431
433
434
+ $ driver = $ this ->_getMockedDriver ();
432
435
$ connection = $ this ->getMock ('Cake\Database\Connection ' , array (), array (), '' , false );
433
- $ driver = new \Cake \Database \Driver \Mysql ();
434
- $ mock = $ this ->getMock ('FakePdo ' , ['quote ' ]);
435
- $ driver ->connection ($ mock );
436
-
437
- $ dialect = new MysqlSchema ($ driver );
438
-
439
436
$ connection ->expects ($ this ->any ())->method ('driver ' )
440
437
->will ($ this ->returnValue ($ driver ));
441
438
442
- $ mock ->expects ($ this ->any ())
443
- ->method ('quote ' )
444
- ->will ($ this ->returnCallback (function ($ value ) {
445
- return '" ' . $ value . '" ' ;
446
- }));
447
-
448
439
$ result = $ table ->createTableSql ($ connection );
449
440
$ expected = <<<SQL
450
441
CREATE TABLE `posts` (
@@ -463,16 +454,16 @@ public function testCreateTableSql() {
463
454
*
464
455
* @return MysqlSchema
465
456
*/
466
- protected function _getMockedSchema () {
457
+ protected function _getMockedDriver () {
467
458
$ driver = new \Cake \Database \Driver \Mysql ();
468
- $ mock = $ this ->getMock ('FakePdo ' , ['quote ' ]);
459
+ $ mock = $ this ->getMock ('FakePdo ' , ['quote ' , ' quoteIdentifier ' ]);
469
460
$ mock ->expects ($ this ->any ())
470
461
->method ('quote ' )
471
462
->will ($ this ->returnCallback (function ($ value ) {
472
463
return '" ' . $ value . '" ' ;
473
464
}));
474
465
$ driver ->connection ($ mock );
475
- return new MysqlSchema ( $ driver) ;
466
+ return $ driver ;
476
467
}
477
468
478
469
}
0 commit comments