mirror of
https://github.com/dg/dibi.git
synced 2025-08-22 13:43:12 +02:00
new directory structure, moved to /src
This commit is contained in:
58
tests/dibi/Fluent.insert.phpt
Normal file
58
tests/dibi/Fluent.insert.phpt
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
|
||||
|
||||
$arr = array(
|
||||
'title' => 'Super Product',
|
||||
'price' => 12,
|
||||
'brand' => NULL,
|
||||
);
|
||||
|
||||
$fluent = $conn->insert('table', $arr)
|
||||
->setFlag('IGNORE')->setFlag('DELAYED');
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT IGNORE DELAYED INTO [table] ([title], [price], [brand]) VALUES (\'Super Product\', 12, NULL)'),
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
$fluent->setFlag('IGNORE', FALSE);
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT DELAYED INTO [table] ([title], [price], [brand]) VALUES (\'Super Product\', 12, NULL)'),
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
$fluent->setFlag('HIGH_priority');
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT DELAYED HIGH_PRIORITY INTO [table] ([title], [price], [brand]) VALUES (\'Super Product\', 12, NULL)'),
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
$fluent->into('anotherTable');
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT DELAYED HIGH_PRIORITY INTO [anotherTable] VALUES (\'Super Product\', 12, NULL)'),
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
$fluent->values('%l', $arr);
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT DELAYED HIGH_PRIORITY INTO [anotherTable] VALUES (\'Super Product\', 12, NULL) , (\'Super Product\', 12, NULL)'),
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
$fluent->values($arr);
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT DELAYED HIGH_PRIORITY INTO [anotherTable] VALUES (\'Super Product\', 12, NULL) , (\'Super Product\', 12, NULL) , (\'Super Product\', 12, NULL)'),
|
||||
(string) $fluent
|
||||
);
|
Reference in New Issue
Block a user