SqliteSchemaTest.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <?php
  2. /**
  3. * PHP Version 5.4
  4. *
  5. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  6. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * For full copyright and license information, please see the LICENSE.txt
  10. * Redistributions of files must retain the above copyright notice.
  11. *
  12. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  13. * @link http://cakephp.org CakePHP(tm) Project
  14. * @since CakePHP(tm) v 3.0.0
  15. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  16. */
  17. namespace Cake\Test\TestCase\Database\Schema;
  18. use Cake\Core\Configure;
  19. use Cake\Database\ConnectionManager;
  20. use Cake\Database\Schema\Collection as SchemaCollection;
  21. use Cake\Database\Schema\SqliteSchema;
  22. use Cake\Database\Schema\Table;
  23. use Cake\TestSuite\TestCase;
  24. /**
  25. * Test case for Sqlite Schema Dialect.
  26. */
  27. class SqliteSchemaTest extends TestCase {
  28. /**
  29. * Helper method for skipping tests that need a real connection.
  30. *
  31. * @return void
  32. */
  33. protected function _needsConnection() {
  34. $config = ConnectionManager::config('test');
  35. $this->skipIf(strpos($config['className'], 'Sqlite') === false, 'Not using Sqlite for test config');
  36. }
  37. /**
  38. * Data provider for convert column testing
  39. *
  40. * @return array
  41. */
  42. public static function convertColumnProvider() {
  43. return [
  44. [
  45. 'DATETIME',
  46. ['type' => 'datetime', 'length' => null]
  47. ],
  48. [
  49. 'DATE',
  50. ['type' => 'date', 'length' => null]
  51. ],
  52. [
  53. 'TIME',
  54. ['type' => 'time', 'length' => null]
  55. ],
  56. [
  57. 'BOOLEAN',
  58. ['type' => 'boolean', 'length' => null]
  59. ],
  60. [
  61. 'BIGINT',
  62. ['type' => 'biginteger', 'length' => null]
  63. ],
  64. [
  65. 'VARCHAR(255)',
  66. ['type' => 'string', 'length' => 255]
  67. ],
  68. [
  69. 'CHAR(25)',
  70. ['type' => 'string', 'fixed' => true, 'length' => 25]
  71. ],
  72. [
  73. 'BLOB',
  74. ['type' => 'binary', 'length' => null]
  75. ],
  76. [
  77. 'INTEGER(11)',
  78. ['type' => 'integer', 'length' => 11]
  79. ],
  80. [
  81. 'TINYINT(5)',
  82. ['type' => 'integer', 'length' => 5]
  83. ],
  84. [
  85. 'MEDIUMINT(10)',
  86. ['type' => 'integer', 'length' => 10]
  87. ],
  88. [
  89. 'FLOAT',
  90. ['type' => 'float', 'length' => null]
  91. ],
  92. [
  93. 'DOUBLE',
  94. ['type' => 'float', 'length' => null]
  95. ],
  96. [
  97. 'REAL',
  98. ['type' => 'float', 'length' => null]
  99. ],
  100. [
  101. 'DECIMAL(11,2)',
  102. ['type' => 'decimal', 'length' => null]
  103. ],
  104. ];
  105. }
  106. /**
  107. * Test parsing SQLite column types from field description.
  108. *
  109. * @dataProvider convertColumnProvider
  110. * @return void
  111. */
  112. public function testConvertColumn($type, $expected) {
  113. $field = [
  114. 'pk' => false,
  115. 'name' => 'field',
  116. 'type' => $type,
  117. 'notnull' => false,
  118. 'dflt_value' => 'Default value',
  119. ];
  120. $expected += [
  121. 'null' => true,
  122. 'default' => 'Default value',
  123. ];
  124. $driver = $this->getMock('Cake\Database\Driver\Sqlite');
  125. $dialect = new SqliteSchema($driver);
  126. $table = $this->getMock('Cake\Database\Schema\Table', [], ['table']);
  127. $table->expects($this->at(0))->method('addColumn')->with('field', $expected);
  128. $dialect->convertFieldDescription($table, $field);
  129. }
  130. /**
  131. * Creates tables for testing listTables/describe()
  132. *
  133. * @param Connection $connection
  134. * @return void
  135. */
  136. protected function _createTables($connection) {
  137. $this->_needsConnection();
  138. $connection->execute('DROP TABLE IF EXISTS schema_articles');
  139. $connection->execute('DROP TABLE IF EXISTS schema_authors');
  140. $table = <<<SQL
  141. CREATE TABLE schema_authors (
  142. id INTEGER PRIMARY KEY AUTOINCREMENT,
  143. name VARCHAR(50),
  144. bio TEXT,
  145. created DATETIME
  146. )
  147. SQL;
  148. $connection->execute($table);
  149. $table = <<<SQL
  150. CREATE TABLE schema_articles (
  151. id INTEGER PRIMARY KEY AUTOINCREMENT,
  152. title VARCHAR(20) DEFAULT 'testing',
  153. body TEXT,
  154. author_id INT(11) NOT NULL,
  155. published BOOLEAN DEFAULT 0,
  156. created DATETIME,
  157. CONSTRAINT "title_idx" UNIQUE ("title", "body")
  158. CONSTRAINT "author_idx" FOREIGN KEY ("author_id") REFERENCES "schema_authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT
  159. );
  160. SQL;
  161. $connection->execute($table);
  162. $connection->execute('CREATE INDEX "created_idx" ON "schema_articles" ("created")');
  163. }
  164. /**
  165. * Test SchemaCollection listing tables with Sqlite
  166. *
  167. * @return void
  168. */
  169. public function testListTables() {
  170. $connection = ConnectionManager::get('test');
  171. $this->_createTables($connection);
  172. $schema = new SchemaCollection($connection);
  173. $result = $schema->listTables();
  174. $this->assertInternalType('array', $result);
  175. $this->assertCount(3, $result);
  176. $this->assertEquals('schema_articles', $result[0]);
  177. $this->assertEquals('schema_authors', $result[1]);
  178. $this->assertEquals('sqlite_sequence', $result[2]);
  179. }
  180. /**
  181. * Test describing a table with Sqlite
  182. *
  183. * @return void
  184. */
  185. public function testDescribeTable() {
  186. $connection = ConnectionManager::get('test');
  187. $this->_createTables($connection);
  188. $schema = new SchemaCollection($connection);
  189. $result = $schema->describe('schema_articles');
  190. $expected = [
  191. 'id' => [
  192. 'type' => 'integer',
  193. 'null' => false,
  194. 'default' => null,
  195. 'length' => null,
  196. 'precision' => null,
  197. 'fixed' => null,
  198. 'comment' => null,
  199. ],
  200. 'title' => [
  201. 'type' => 'string',
  202. 'null' => true,
  203. 'default' => 'testing',
  204. 'length' => 20,
  205. 'precision' => null,
  206. 'fixed' => null,
  207. 'comment' => null,
  208. ],
  209. 'body' => [
  210. 'type' => 'text',
  211. 'null' => true,
  212. 'default' => null,
  213. 'length' => null,
  214. 'precision' => null,
  215. 'fixed' => null,
  216. 'comment' => null,
  217. ],
  218. 'author_id' => [
  219. 'type' => 'integer',
  220. 'null' => false,
  221. 'default' => null,
  222. 'length' => 11,
  223. 'precision' => null,
  224. 'fixed' => null,
  225. 'comment' => null,
  226. ],
  227. 'published' => [
  228. 'type' => 'boolean',
  229. 'null' => true,
  230. 'default' => 0,
  231. 'length' => null,
  232. 'precision' => null,
  233. 'fixed' => null,
  234. 'comment' => null,
  235. ],
  236. 'created' => [
  237. 'type' => 'datetime',
  238. 'null' => true,
  239. 'default' => null,
  240. 'length' => null,
  241. 'precision' => null,
  242. 'fixed' => null,
  243. 'comment' => null,
  244. ],
  245. ];
  246. $this->assertInstanceOf('Cake\Database\Schema\Table', $result);
  247. $this->assertEquals(['id'], $result->primaryKey());
  248. foreach ($expected as $field => $definition) {
  249. $this->assertEquals($definition, $result->column($field));
  250. }
  251. }
  252. /**
  253. * Test describing a table with indexes
  254. *
  255. * @return void
  256. */
  257. public function testDescribeTableIndexes() {
  258. $connection = ConnectionManager::get('test');
  259. $this->_createTables($connection);
  260. $schema = new SchemaCollection($connection);
  261. $result = $schema->describe('schema_articles');
  262. $this->assertInstanceOf('Cake\Database\Schema\Table', $result);
  263. $expected = [
  264. 'primary' => [
  265. 'type' => 'primary',
  266. 'columns' => ['id'],
  267. 'length' => []
  268. ],
  269. 'sqlite_autoindex_schema_articles_1' => [
  270. 'type' => 'unique',
  271. 'columns' => ['title', 'body'],
  272. 'length' => []
  273. ],
  274. 'author_id_fk' => [
  275. 'type' => 'foreign',
  276. 'columns' => ['author_id'],
  277. 'references' => ['schema_authors', 'id'],
  278. 'length' => [],
  279. 'update' => 'cascade',
  280. 'delete' => 'restrict',
  281. ]
  282. ];
  283. $this->assertCount(3, $result->constraints());
  284. $this->assertEquals($expected['primary'], $result->constraint('primary'));
  285. $this->assertEquals(
  286. $expected['sqlite_autoindex_schema_articles_1'],
  287. $result->constraint('sqlite_autoindex_schema_articles_1')
  288. );
  289. $this->assertEquals(
  290. $expected['author_id_fk'],
  291. $result->constraint('author_id_fk')
  292. );
  293. $this->assertCount(1, $result->indexes());
  294. $expected = [
  295. 'type' => 'index',
  296. 'columns' => ['created'],
  297. 'length' => []
  298. ];
  299. $this->assertEquals($expected, $result->index('created_idx'));
  300. }
  301. /**
  302. * Column provider for creating column sql
  303. *
  304. * @return array
  305. */
  306. public static function columnSqlProvider() {
  307. return [
  308. // strings
  309. [
  310. 'title',
  311. ['type' => 'string', 'length' => 25, 'null' => false],
  312. '"title" VARCHAR(25) NOT NULL'
  313. ],
  314. [
  315. 'title',
  316. ['type' => 'string', 'length' => 25, 'null' => true, 'default' => 'ignored'],
  317. '"title" VARCHAR(25) DEFAULT NULL'
  318. ],
  319. [
  320. 'id',
  321. ['type' => 'string', 'length' => 32, 'fixed' => true, 'null' => false],
  322. '"id" VARCHAR(32) NOT NULL'
  323. ],
  324. [
  325. 'role',
  326. ['type' => 'string', 'length' => 10, 'null' => false, 'default' => 'admin'],
  327. '"role" VARCHAR(10) NOT NULL DEFAULT "admin"'
  328. ],
  329. [
  330. 'title',
  331. ['type' => 'string'],
  332. '"title" VARCHAR'
  333. ],
  334. // Text
  335. [
  336. 'body',
  337. ['type' => 'text', 'null' => false],
  338. '"body" TEXT NOT NULL'
  339. ],
  340. // Integers
  341. [
  342. 'post_id',
  343. ['type' => 'integer', 'length' => 11],
  344. '"post_id" INTEGER(11)'
  345. ],
  346. [
  347. 'post_id',
  348. ['type' => 'biginteger', 'length' => 20],
  349. '"post_id" BIGINT'
  350. ],
  351. // Decimal
  352. [
  353. 'value',
  354. ['type' => 'decimal'],
  355. '"value" DECIMAL'
  356. ],
  357. [
  358. 'value',
  359. ['type' => 'decimal', 'length' => 11],
  360. '"value" DECIMAL(11,0)'
  361. ],
  362. [
  363. 'value',
  364. ['type' => 'decimal', 'length' => 12, 'precision' => 5],
  365. '"value" DECIMAL(12,5)'
  366. ],
  367. // Float
  368. [
  369. 'value',
  370. ['type' => 'float'],
  371. '"value" FLOAT'
  372. ],
  373. [
  374. 'value',
  375. ['type' => 'float', 'length' => 11, 'precision' => 3],
  376. '"value" FLOAT(11,3)'
  377. ],
  378. // Boolean
  379. [
  380. 'checked',
  381. ['type' => 'boolean', 'default' => false],
  382. '"checked" BOOLEAN DEFAULT FALSE'
  383. ],
  384. [
  385. 'checked',
  386. ['type' => 'boolean', 'default' => true, 'null' => false],
  387. '"checked" BOOLEAN NOT NULL DEFAULT TRUE'
  388. ],
  389. // datetimes
  390. [
  391. 'created',
  392. ['type' => 'datetime'],
  393. '"created" DATETIME'
  394. ],
  395. // Date & Time
  396. [
  397. 'start_date',
  398. ['type' => 'date'],
  399. '"start_date" DATE'
  400. ],
  401. [
  402. 'start_time',
  403. ['type' => 'time'],
  404. '"start_time" TIME'
  405. ],
  406. // timestamps
  407. [
  408. 'created',
  409. ['type' => 'timestamp', 'null' => true],
  410. '"created" TIMESTAMP DEFAULT NULL'
  411. ],
  412. ];
  413. }
  414. /**
  415. * Test generating column definitions
  416. *
  417. * @dataProvider columnSqlProvider
  418. * @return void
  419. */
  420. public function testColumnSql($name, $data, $expected) {
  421. $driver = $this->_getMockedDriver();
  422. $schema = new SqliteSchema($driver);
  423. $table = (new Table('articles'))->addColumn($name, $data);
  424. $this->assertEquals($expected, $schema->columnSql($table, $name));
  425. }
  426. /**
  427. * Test generating a column that is a primary key.
  428. *
  429. * @return void
  430. */
  431. public function testColumnSqlPrimaryKey() {
  432. $driver = $this->_getMockedDriver();
  433. $schema = new SqliteSchema($driver);
  434. $table = new Table('articles');
  435. $table->addColumn('id', [
  436. 'type' => 'integer',
  437. 'null' => false
  438. ])
  439. ->addConstraint('primary', [
  440. 'type' => 'primary',
  441. 'columns' => ['id']
  442. ]);
  443. $result = $schema->columnSql($table, 'id');
  444. $this->assertEquals($result, '"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT');
  445. $result = $schema->constraintSql($table, 'primary');
  446. $this->assertEquals('', $result, 'Integer primary keys are special in sqlite.');
  447. }
  448. /**
  449. * Test generating a bigint column that is a primary key.
  450. *
  451. * @return void
  452. */
  453. public function testColumnSqlPrimaryKeyBigInt() {
  454. $driver = $this->_getMockedDriver();
  455. $schema = new SqliteSchema($driver);
  456. $table = new Table('articles');
  457. $table->addColumn('id', [
  458. 'type' => 'biginteger',
  459. 'null' => false
  460. ])
  461. ->addConstraint('primary', [
  462. 'type' => 'primary',
  463. 'columns' => ['id']
  464. ]);
  465. $result = $schema->columnSql($table, 'id');
  466. $this->assertEquals($result, '"id" BIGINT NOT NULL');
  467. $result = $schema->constraintSql($table, 'primary');
  468. $this->assertEquals('CONSTRAINT "primary" PRIMARY KEY ("id")', $result, 'Bigint primary keys are not special.');
  469. }
  470. /**
  471. * Provide data for testing constraintSql
  472. *
  473. * @return array
  474. */
  475. public static function constraintSqlProvider() {
  476. return [
  477. [
  478. 'primary',
  479. ['type' => 'primary', 'columns' => ['title']],
  480. 'CONSTRAINT "primary" PRIMARY KEY ("title")'
  481. ],
  482. [
  483. 'unique_idx',
  484. ['type' => 'unique', 'columns' => ['title', 'author_id']],
  485. 'CONSTRAINT "unique_idx" UNIQUE ("title", "author_id")'
  486. ],
  487. [
  488. 'author_id_idx',
  489. ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id']],
  490. 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
  491. 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT'
  492. ],
  493. [
  494. 'author_id_idx',
  495. ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'cascade'],
  496. 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
  497. 'REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT'
  498. ],
  499. [
  500. 'author_id_idx',
  501. ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'restrict'],
  502. 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
  503. 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT'
  504. ],
  505. [
  506. 'author_id_idx',
  507. ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'setNull'],
  508. 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
  509. 'REFERENCES "authors" ("id") ON UPDATE SET NULL ON DELETE RESTRICT'
  510. ],
  511. [
  512. 'author_id_idx',
  513. ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'noAction'],
  514. 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
  515. 'REFERENCES "authors" ("id") ON UPDATE NO ACTION ON DELETE RESTRICT'
  516. ],
  517. ];
  518. }
  519. /**
  520. * Test the constraintSql method.
  521. *
  522. * @dataProvider constraintSqlProvider
  523. */
  524. public function testConstraintSql($name, $data, $expected) {
  525. $driver = $this->_getMockedDriver();
  526. $schema = new SqliteSchema($driver);
  527. $table = (new Table('articles'))->addColumn('title', [
  528. 'type' => 'string',
  529. 'length' => 255
  530. ])->addColumn('author_id', [
  531. 'type' => 'integer',
  532. ])->addConstraint($name, $data);
  533. $this->assertEquals($expected, $schema->constraintSql($table, $name));
  534. }
  535. /**
  536. * Provide data for testing indexSql
  537. *
  538. * @return array
  539. */
  540. public static function indexSqlProvider() {
  541. return [
  542. [
  543. 'author_idx',
  544. ['type' => 'index', 'columns' => ['title', 'author_id']],
  545. 'CREATE INDEX "author_idx" ON "articles" ("title", "author_id")'
  546. ],
  547. ];
  548. }
  549. /**
  550. * Test the indexSql method.
  551. *
  552. * @dataProvider indexSqlProvider
  553. */
  554. public function testIndexSql($name, $data, $expected) {
  555. $driver = $this->_getMockedDriver();
  556. $schema = new SqliteSchema($driver);
  557. $table = (new Table('articles'))->addColumn('title', [
  558. 'type' => 'string',
  559. 'length' => 255
  560. ])->addColumn('author_id', [
  561. 'type' => 'integer',
  562. ])->addIndex($name, $data);
  563. $this->assertEquals($expected, $schema->indexSql($table, $name));
  564. }
  565. /**
  566. * Integration test for converting a Schema\Table into MySQL table creates.
  567. *
  568. * @return void
  569. */
  570. public function testCreateSql() {
  571. $driver = $this->_getMockedDriver();
  572. $connection = $this->getMock('Cake\Database\Connection', [], [], '', false);
  573. $connection->expects($this->any())->method('driver')
  574. ->will($this->returnValue($driver));
  575. $table = (new Table('articles'))->addColumn('id', [
  576. 'type' => 'integer',
  577. 'null' => false
  578. ])
  579. ->addColumn('title', [
  580. 'type' => 'string',
  581. 'null' => false,
  582. ])
  583. ->addColumn('body', ['type' => 'text'])
  584. ->addColumn('created', 'datetime')
  585. ->addConstraint('primary', [
  586. 'type' => 'primary',
  587. 'columns' => ['id']
  588. ])
  589. ->addIndex('title_idx', [
  590. 'type' => 'index',
  591. 'columns' => ['title']
  592. ]);
  593. $expected = <<<SQL
  594. CREATE TABLE "articles" (
  595. "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  596. "title" VARCHAR NOT NULL,
  597. "body" TEXT,
  598. "created" DATETIME
  599. )
  600. SQL;
  601. $result = $table->createSql($connection);
  602. $this->assertCount(2, $result);
  603. $this->assertEquals($expected, $result[0]);
  604. $this->assertEquals(
  605. 'CREATE INDEX "title_idx" ON "articles" ("title")',
  606. $result[1]
  607. );
  608. }
  609. /**
  610. * test dropSql
  611. *
  612. * @return void
  613. */
  614. public function testDropSql() {
  615. $driver = $this->_getMockedDriver();
  616. $connection = $this->getMock('Cake\Database\Connection', [], [], '', false);
  617. $connection->expects($this->any())->method('driver')
  618. ->will($this->returnValue($driver));
  619. $table = new Table('articles');
  620. $result = $table->dropSql($connection);
  621. $this->assertCount(1, $result);
  622. $this->assertEquals('DROP TABLE "articles"', $result[0]);
  623. }
  624. /**
  625. * Test truncateSql()
  626. *
  627. * @return void
  628. */
  629. public function testTruncateSql() {
  630. $driver = $this->_getMockedDriver();
  631. $connection = $this->getMock('Cake\Database\Connection', [], [], '', false);
  632. $connection->expects($this->any())->method('driver')
  633. ->will($this->returnValue($driver));
  634. $table = new Table('articles');
  635. $result = $table->truncateSql($connection);
  636. $this->assertCount(2, $result);
  637. $this->assertEquals('DELETE FROM sqlite_sequence WHERE name="articles"', $result[0]);
  638. $this->assertEquals('DELETE FROM "articles"', $result[1]);
  639. }
  640. /**
  641. * Get a schema instance with a mocked driver/pdo instances
  642. *
  643. * @return Driver
  644. */
  645. protected function _getMockedDriver() {
  646. $driver = new \Cake\Database\Driver\Sqlite();
  647. $mock = $this->getMock('FakePdo', ['quote', 'quoteIdentifier']);
  648. $mock->expects($this->any())
  649. ->method('quote')
  650. ->will($this->returnCallback(function ($value) {
  651. return '"' . $value . '"';
  652. }));
  653. $mock->expects($this->any())
  654. ->method('quoteIdentifier')
  655. ->will($this->returnCallback(function ($value) {
  656. return '"' . $value . '"';
  657. }));
  658. $driver->connection($mock);
  659. return $driver;
  660. }
  661. }