3
namespace Upside\Db\Test\SQL;
5
use Upside\Db\SQL\Expression;
7
class InsertTest extends BaseClass
9
public function testInsertSingleValue()
11
$expected = 'INSERT INTO "users" ("age") VALUES (18)';
12
$actual = $this->db->insert(['age' => 18])->into('users');
13
$this->assertEquals($expected, $actual);
16
public function testInsertMultipleValues()
18
$expected = 'INSERT INTO "users" ("name", "age") VALUES (\'foo\', 18)';
19
$actual = $this->db->insert(['name' => 'foo', 'age' => 18])->into('users');
20
$this->assertEquals($expected, $actual);
23
public function testInsertBooleanValues()
25
$expected = 'INSERT INTO "test" ("foo", "bar") VALUES (TRUE, FALSE)';
26
$actual = $this->db->insert(['foo' => true, 'bar' => false])->into('test');
27
$this->assertEquals($expected, $actual);
30
public function testInsertExpressions()
32
$expected = 'INSERT INTO "users" ("name") VALUES (LCASE( \'foo\' ))';
33
$actual = $this->db->insert([
34
'name' => function (Expression $expr) {
35
$expr->{'LCASE('}->value('foo')->{')'};
38
$this->assertEquals($expected, $actual);