/** * @test */ public function sqlForInsertWithMultipleRowsIsValid() { $fields = array('uid', 'pid', 'title', 'body'); $rows = array(array('1', '2', 'Title #1', 'Content #1'), array('3', '4', 'Title #2', 'Content #2'), array('5', '6', 'Title #3', 'Content #3')); $result = $this->subject->INSERTmultipleRows('tt_content', $fields, $rows); $expected = 'INSERT INTO tt_content (uid, pid, title, body) VALUES '; $expected .= '(\'1\', \'2\', \'Title #1\', \'Content #1\'), '; $expected .= '(\'3\', \'4\', \'Title #2\', \'Content #2\'), '; $expected .= '(\'5\', \'6\', \'Title #3\', \'Content #3\')'; $this->assertEquals($expected, $this->cleanSql($result)); }
/** * @test */ public function sqlForInsertWithMultipleRowsIsValid() { $fields = array('uid', 'pid', 'title', 'body'); $rows = array(array('1', '2', 'Title #1', 'Content #1'), array('3', '4', 'Title #2', 'Content #2'), array('5', '6', 'Title #3', 'Content #3')); $result = $this->subject->INSERTmultipleRows('tt_content', $fields, $rows); $expected[0] = 'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'1\', \'2\', \'Title #1\', \'Content #1\' )'; $expected[1] = 'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'3\', \'4\', \'Title #2\', \'Content #2\' )'; $expected[2] = 'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'5\', \'6\', \'Title #3\', \'Content #3\' )'; $this->assertEquals(count($expected), count($result)); for ($i = 0; $i < count($result); $i++) { $this->assertTrue(is_array($result[$i]), 'Expected array: ' . $result[$i]); $this->assertEquals(1, count($result[$i])); $this->assertEquals($expected[$i], $this->cleanSql($result[$i][0])); } }