-
-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathSelection.insert().phpt
More file actions
51 lines (39 loc) · 1.26 KB
/
Selection.insert().phpt
File metadata and controls
51 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
49
50
51
<?php
/**
* @dataProvider? ../../databases.ini
*/
use Tester\Assert;
require __DIR__ . '/../../connect.inc.php'; // create $connection
Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../../files/{$driverName}-nette_test4.sql");
//Insert into table without auto_increament primary key
test(function () use ($context) {
$inserted = $context->table('simple_pk')->insert([
'id' => 8,
'name' => 'Michal'
]);
Assert::equal(8, $inserted->id);
Assert::equal('Michal', $inserted->name);
});
//Insert into table with composite primary key
test(function () use ($context) {
$inserted = $context->table('composite_pk')->insert([
'id1' => 8,
'id2' => 10,
'name' => 'Michal'
]);
Assert::equal(8, $inserted->id1);
Assert::equal(10, $inserted->id2);
Assert::equal('Michal', $inserted->name);
});
//Insert into table with composite primary key and one of them is auto_increment
test(function () use ($context, $driverName) {
//Sqlite doesn't allow this type of table and sqlsrv's driver don't implement reflection
if ($driverName == 'mysql' || $driverName == 'pgsql') {
$inserted = $context->table('composite_pk_ai')->insert([
'id2' => 10,
'name' => 'Michal'
]);
Assert::equal(10, $inserted->id2);
Assert::equal('Michal', $inserted->name);
}
});