[NFC][test-fix] centralise use of assertLike for comparing sql
[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(array('first' => '1', 'second' => '2'))
12 ->row(array('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(array('first' => '1', 'second' => '2'))
24 ->rows(array(
25 array('second' => '2b', 'first' => '1b'),
26 array('first' => '1c', 'second' => '2c'),
27 ))
28 ->row(array('second' => '2d', 'first' => '1d'));
29 $expected = '
30 INSERT INTO foo (`first`,`second`) VALUES
31 ("1","2"),
32 ("1b","2b"),
33 ("1c","2c"),
34 ("1d","2d")
35 ';
36 $this->assertLike($expected, $insert->toSQL());
37 }
38
39 }