forked from etsy/411
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDBTest.php
More file actions
33 lines (27 loc) · 1.07 KB
/
Copy pathDBTest.php
File metadata and controls
33 lines (27 loc) · 1.07 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
<?php
class DBTest extends TestCase {
public function testInsertId() {
$sql = sprintf('INSERT INTO `%s` VALUES (0, ?, ?)', FOO\DBMeta::$TABLE);
FOO\DB::query($sql, ['a', 'b']);
$id = FOO\DB::insertId();
FOO\DB::query($sql, ['c', 'd']);
$id_ = FOO\DB::insertId();
$this->assertGreaterThan($id, $id_);
}
public function testInPlaceholder() {
$this->assertSame('(NULL)', FOO\DB::inPlaceholder(0));
$this->assertSame('(?)', FOO\DB::inPlaceholder(1));
}
public function testKPlaceholder() {
$this->assertSame('`x`', FOO\DB::kPlaceholder('x'));
$this->assertSame('`y`.`x`', FOO\DB::kPlaceholder('x', 'y'));
}
public function testKVPlaceholder() {
$this->assertSame('`x` = ?', FOO\DB::kvPlaceholder('x'));
$this->assertSame('`y`.`x` = ?', FOO\DB::kvPlaceholder('x', 'y'));
}
public function testKVPlaceholders() {
$this->assertSame(['`x` = ?', '`y` = ?'], FOO\DB::kvPlaceholders(['x', 'y']));
$this->assertSame([], FOO\DB::kvPlaceholders([]));
}
}