mirror of
https://github.com/dg/dibi.git
synced 2025-08-03 12:47:33 +02:00
tests: fixes
This commit is contained in:
Binary file not shown.
@@ -12,16 +12,6 @@ $conn = new DibiConnection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
|
||||
function num($n)
|
||||
{
|
||||
global $config;
|
||||
if (substr(@$config['dsn'], 0, 5) === 'odbc:' || $config['driver'] === 'sqlite') {
|
||||
$n = is_float($n) ? "$n.0" : (string) $n;
|
||||
}
|
||||
return $n;
|
||||
}
|
||||
|
||||
|
||||
// fetch a single value
|
||||
$res = $conn->query('SELECT [title] FROM [products]');
|
||||
Assert::same('Chair', $res->fetchSingle());
|
||||
|
@@ -12,16 +12,6 @@ $conn = new DibiConnection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
|
||||
function num($n)
|
||||
{
|
||||
global $config;
|
||||
if (substr(@$config['dsn'], 0, 5) === 'odbc:' || $config['driver'] === 'sqlite') {
|
||||
$n = is_float($n) ? "$n.0" : (string) $n;
|
||||
}
|
||||
return $n;
|
||||
}
|
||||
|
||||
|
||||
// fetch a single value
|
||||
$res = $conn->select('title')->from('products')->orderBy('product_id');
|
||||
Assert::equal('Chair', $res->fetchSingle());
|
||||
|
@@ -80,16 +80,6 @@ Assert::same(
|
||||
);
|
||||
|
||||
|
||||
try {
|
||||
$fluent = $conn->select('*')->from('table')->fetch();
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
Assert::same(
|
||||
reformat(' SELECT * FROM [table] LIMIT 1'),
|
||||
dibi::$sql
|
||||
);
|
||||
|
||||
|
||||
$fluent = $conn->select('*')
|
||||
->select(
|
||||
$conn->select('count(*)')
|
||||
|
@@ -35,8 +35,8 @@ Assert::false(isset($row['missing']));
|
||||
|
||||
|
||||
// to array
|
||||
Assert::same(array('product_id' => 1, 'title' => 'Chair'), iterator_to_array($row));
|
||||
Assert::same(array('product_id' => 1, 'title' => 'Chair'), $row->toArray());
|
||||
Assert::same(array('product_id' => num(1), 'title' => 'Chair'), iterator_to_array($row));
|
||||
Assert::same(array('product_id' => num(1), 'title' => 'Chair'), $row->toArray());
|
||||
|
||||
// counting
|
||||
Assert::same(2, count($row));
|
||||
|
@@ -69,3 +69,13 @@ function reformat($s)
|
||||
trigger_error("Unsupported driver $config[system]", E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function num($n)
|
||||
{
|
||||
global $config;
|
||||
if (substr(@$config['dsn'], 0, 5) === 'odbc:' || $config['driver'] === 'sqlite') {
|
||||
$n = is_float($n) ? "$n.0" : (string) $n;
|
||||
}
|
||||
return $n;
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ INSERT INTO `customers` (`customer_id`, `name`) VALUES (5, 'Kryten');
|
||||
INSERT INTO `customers` (`customer_id`, `name`) VALUES (6, 'Kristine Kochanski');
|
||||
|
||||
CREATE TABLE [orders] (
|
||||
[order_id] INTEGER,
|
||||
[order_id] COUNTER,
|
||||
[customer_id] INTEGER,
|
||||
[product_id] INTEGER,
|
||||
[amount] FLOAT
|
||||
|
Reference in New Issue
Block a user