SqlserverSchemaTest.php 17 KB

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