-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertTest.php
More file actions
48 lines (39 loc) · 1.26 KB
/
InsertTest.php
File metadata and controls
48 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Sirius\Sql\Tests;
use PHPUnit\Framework\TestCase;
use Sirius\Sql\Insert;
class InsertTest extends QueryTestCase
{
/**
* @return Insert
*/
public function newInsert()
{
return new Insert($this->getConnectionMock());
}
public function test_statement_and_bindings()
{
/** @var Insert $insert */
$insert = $this->newInsert()
->ignore()
->into('posts')
->columns(['title' => 'abc', 'content' => 'xyz', 'publish_date'])
->returning('title', 'content')
->returning('publish_date');
$statement = <<<SQL
INSERT IGNORE INTO posts
(`title`, `content`, `publish_date`)
VALUES
(:title, :content, :publish_date)
RETURNING
title, content, publish_date
SQL;
$this->assertSameStatement($statement, $insert->getStatement());
$bindings = $insert->getBindValues();
$this->assertTrue(isset($bindings['title']));
$this->assertTrue(isset($bindings['content']));
$this->assertFalse(isset($bindings['publish_date']));
$this->assertTrue($insert->hasColumns());
$this->assertEquals('id-1', $insert->getLastInsertId('id'));
}
}