1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-03 12:47:33 +02:00

tests: fixes

This commit is contained in:
David Grudl
2015-11-04 15:17:10 +01:00
parent 120f0946e0
commit 8f8fd040ff
10 changed files with 58 additions and 78 deletions

Binary file not shown.

View File

@@ -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());

View File

@@ -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());

View File

@@ -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(*)')

View File

@@ -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));

View File

@@ -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;
}

View File

@@ -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