Autoformat /tests directory with php short array syntax
[civicrm-core.git] / tests / phpunit / CRM / Utils / SQL / InsertTest.php
1 <?php
2
3 /**
4 * Class CRM_Utils_SQL_SelectTest
5 * @group headless
6 */
7 class CRM_Utils_SQL_InsertTest extends CiviUnitTestCase {
8
9 public function testRow_twice() {
10 $insert = CRM_Utils_SQL_Insert::into('foo')
11 ->row(['first' => '1', 'second' => '2'])
12 ->row(['second' => '2b', 'first' => '1b']);
13 $expected = '
14 INSERT INTO foo (`first`,`second`) VALUES
15 ("1","2"),
16 ("1b","2b")
17 ';
18 $this->assertLike($expected, $insert->toSQL());
19 }
20
21 public function testRows() {
22 $insert = CRM_Utils_SQL_Insert::into('foo')
23 ->row(['first' => '1', 'second' => '2'])
24 ->rows([
25 ['second' => '2b', 'first' => '1b'],
26 ['first' => '1c', 'second' => '2c'],
27 ])
28 ->row(['second' => '2d', 'first' => '1d'])
29 ->row(['first' => NULL, 'second' => '2e']);
30 $expected = '
31 INSERT INTO foo (`first`,`second`) VALUES
32 ("1","2"),
33 ("1b","2b"),
34 ("1c","2c"),
35 ("1d","2d"),
36 (NULL,"2e")
37 ';
38 $this->assertLike($expected, $insert->toSQL());
39 }
40
41 }