83a2c7c409d63a1225b22e345a7d0dc51cb9cb17
2 require_once 'CiviTest/CiviUnitTestCase.php';
5 * Class CRM_Utils_SQL_SelectTest
7 class CRM_Utils_SQL_InsertTest
extends CiviUnitTestCase
{
8 public function testRow_twice() {
9 $insert = CRM_Utils_SQL_Insert
::into('foo')
10 ->row(array('first' => '1', 'second' => '2'))
11 ->row(array('second' => '2b', 'first' => '1b'));
13 INSERT INTO foo (`first`,`second`) VALUES
17 $this->assertLike($expected, $insert->toSQL());
20 public function testRows() {
21 $insert = CRM_Utils_SQL_Insert
::into('foo')
22 ->row(array('first' => '1', 'second' => '2'))
24 array('second' => '2b', 'first' => '1b'),
25 array('first' => '1c', 'second' => '2c'),
27 ->row(array('second' => '2d', 'first' => '1d'));
29 INSERT INTO foo (`first`,`second`) VALUES
35 $this->assertLike($expected, $insert->toSQL());
41 * @param string $message
43 public function assertLike($expected, $actual, $message = '') {
44 $expected = trim((preg_replace('/[ \r\n\t]+/', ' ', $expected)));
45 $actual = trim((preg_replace('/[ \r\n\t]+/', ' ', $actual)));
46 $this->assertEquals($expected, $actual, $message);