mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
moved to namespace Dibi
added loader for old class names
This commit is contained in:
@@ -8,7 +8,7 @@ use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
|
||||
|
@@ -5,12 +5,13 @@
|
||||
*/
|
||||
|
||||
use Tester\Assert;
|
||||
use Dibi\Connection;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
test(function () use ($config) {
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Connection($config);
|
||||
Assert::true($conn->isConnected());
|
||||
|
||||
$conn->disconnect();
|
||||
@@ -19,7 +20,7 @@ test(function () use ($config) {
|
||||
|
||||
|
||||
test(function () use ($config) { // lazy
|
||||
$conn = new DibiConnection($config + ['lazy' => TRUE]);
|
||||
$conn = new Connection($config + ['lazy' => TRUE]);
|
||||
Assert::false($conn->isConnected());
|
||||
|
||||
$conn->query('SELECT 1');
|
||||
@@ -28,10 +29,10 @@ test(function () use ($config) { // lazy
|
||||
|
||||
|
||||
test(function () use ($config) { // query string
|
||||
$conn = new DibiConnection(http_build_query($config, NULL, '&'));
|
||||
$conn = new Connection(http_build_query($config, NULL, '&'));
|
||||
Assert::true($conn->isConnected());
|
||||
|
||||
Assert::null($conn->getConfig('lazy'));
|
||||
Assert::same($config['driver'], $conn->getConfig('driver'));
|
||||
Assert::type('IDibiDriver', $conn->getDriver());
|
||||
Assert::type('Dibi\Driver', $conn->getDriver());
|
||||
});
|
||||
|
@@ -5,10 +5,11 @@
|
||||
*/
|
||||
|
||||
use Tester\Assert;
|
||||
use Dibi\Row;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
|
||||
@@ -30,9 +31,9 @@ Assert::same('Chair', $res->fetchSingle());
|
||||
// fetch complete result set
|
||||
$res = $conn->query('SELECT * FROM [products] ORDER BY product_id');
|
||||
Assert::equal([
|
||||
new DibiRow(['product_id' => num(1), 'title' => 'Chair']),
|
||||
new DibiRow(['product_id' => num(2), 'title' => 'Table']),
|
||||
new DibiRow(['product_id' => num(3), 'title' => 'Computer']),
|
||||
new Row(['product_id' => num(1), 'title' => 'Chair']),
|
||||
new Row(['product_id' => num(2), 'title' => 'Table']),
|
||||
new Row(['product_id' => num(3), 'title' => 'Computer']),
|
||||
], $res->fetchAll());
|
||||
|
||||
|
||||
@@ -53,18 +54,18 @@ Assert::same(
|
||||
// fetch row by row
|
||||
$res = $conn->query('SELECT * FROM [products] ORDER BY product_id');
|
||||
Assert::equal([
|
||||
new DibiRow(['product_id' => num(1), 'title' => 'Chair']),
|
||||
new DibiRow(['product_id' => num(2), 'title' => 'Table']),
|
||||
new DibiRow(['product_id' => num(3), 'title' => 'Computer']),
|
||||
new Row(['product_id' => num(1), 'title' => 'Chair']),
|
||||
new Row(['product_id' => num(2), 'title' => 'Table']),
|
||||
new Row(['product_id' => num(3), 'title' => 'Computer']),
|
||||
], iterator_to_array($res));
|
||||
|
||||
|
||||
// fetch complete result set like association array
|
||||
$res = $conn->query('SELECT * FROM [products] ORDER BY product_id');
|
||||
Assert::equal([
|
||||
'Chair' => new DibiRow(['product_id' => num(1), 'title' => 'Chair']),
|
||||
'Table' => new DibiRow(['product_id' => num(2), 'title' => 'Table']),
|
||||
'Computer' => new DibiRow(['product_id' => num(3), 'title' => 'Computer']),
|
||||
'Chair' => new Row(['product_id' => num(1), 'title' => 'Chair']),
|
||||
'Table' => new Row(['product_id' => num(2), 'title' => 'Table']),
|
||||
'Computer' => new Row(['product_id' => num(3), 'title' => 'Computer']),
|
||||
], $res->fetchAssoc('title'));
|
||||
|
||||
|
||||
@@ -90,14 +91,14 @@ function query($conn) {
|
||||
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => [
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
'Dave Lister' => [
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
'Kristine Kochanski' => [
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
], query($conn)->fetchAssoc('name,title'));
|
||||
|
||||
@@ -105,20 +106,20 @@ Assert::equal([
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => [
|
||||
[
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
],
|
||||
[
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
],
|
||||
'Dave Lister' => [
|
||||
[
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
],
|
||||
'Kristine Kochanski' => [
|
||||
[
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
],
|
||||
], query($conn)->fetchAssoc('name,#,title'));
|
||||
@@ -127,22 +128,22 @@ Assert::equal([
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => [
|
||||
'title' => [
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
'name' => 'Arnold Rimmer',
|
||||
'amount' => num(7.0),
|
||||
],
|
||||
'Dave Lister' => [
|
||||
'title' => [
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
'name' => 'Dave Lister',
|
||||
'amount' => num(3.0),
|
||||
],
|
||||
'Kristine Kochanski' => [
|
||||
'title' => [
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
'name' => 'Kristine Kochanski',
|
||||
'amount' => num(5.0),
|
||||
@@ -151,24 +152,24 @@ Assert::equal([
|
||||
|
||||
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => new DibiRow([
|
||||
'Arnold Rimmer' => new Row([
|
||||
'title' => [
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
'name' => 'Arnold Rimmer',
|
||||
'amount' => num(7.0),
|
||||
]),
|
||||
'Dave Lister' => new DibiRow([
|
||||
'Dave Lister' => new Row([
|
||||
'title' => [
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
'name' => 'Dave Lister',
|
||||
'amount' => num(3.0),
|
||||
]),
|
||||
'Kristine Kochanski' => new DibiRow([
|
||||
'Kristine Kochanski' => new Row([
|
||||
'title' => [
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
'name' => 'Kristine Kochanski',
|
||||
'amount' => num(5.0),
|
||||
@@ -177,12 +178,12 @@ Assert::equal([
|
||||
|
||||
|
||||
Assert::equal([
|
||||
new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
new DibiRow([
|
||||
new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
new Row([
|
||||
'title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
new DibiRow([
|
||||
new Row([
|
||||
'title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
new DibiRow([
|
||||
new Row([
|
||||
'title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
], query($conn)->fetchAssoc('@,='));
|
||||
|
||||
@@ -190,22 +191,22 @@ Assert::equal([
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => [
|
||||
'title' => [
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
'name' => 'Arnold Rimmer',
|
||||
'amount' => num(7.0),
|
||||
],
|
||||
'Dave Lister' => [
|
||||
'title' => [
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
'name' => 'Dave Lister',
|
||||
'amount' => num(3.0),
|
||||
],
|
||||
'Kristine Kochanski' => [
|
||||
'title' => [
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
'name' => 'Kristine Kochanski',
|
||||
'amount' => num(5.0),
|
||||
@@ -216,14 +217,14 @@ Assert::equal([
|
||||
// old syntax
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => [
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
'Dave Lister' => [
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
'Kristine Kochanski' => [
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
], query($conn)->fetchAssoc('name|title'));
|
||||
|
||||
@@ -231,44 +232,44 @@ Assert::equal([
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => [
|
||||
[
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
],
|
||||
[
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
],
|
||||
'Dave Lister' => [
|
||||
[
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
],
|
||||
'Kristine Kochanski' => [
|
||||
[
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
],
|
||||
], query($conn)->fetchAssoc('name[]title'));
|
||||
|
||||
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => new DibiRow([
|
||||
'Arnold Rimmer' => new Row([
|
||||
'title' => [
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
'name' => 'Arnold Rimmer',
|
||||
'amount' => num(7.0),
|
||||
]),
|
||||
'Dave Lister' => new DibiRow([
|
||||
'Dave Lister' => new Row([
|
||||
'title' => [
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
'name' => 'Dave Lister',
|
||||
'amount' => num(3.0),
|
||||
]),
|
||||
'Kristine Kochanski' => new DibiRow([
|
||||
'Kristine Kochanski' => new Row([
|
||||
'title' => [
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
'name' => 'Kristine Kochanski',
|
||||
'amount' => num(5.0),
|
||||
@@ -277,17 +278,17 @@ Assert::equal([
|
||||
|
||||
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => new DibiRow([
|
||||
'Arnold Rimmer' => new Row([
|
||||
'title' => ['Chair' => 'Arnold Rimmer', 'Computer' => 'Arnold Rimmer'],
|
||||
'name' => 'Arnold Rimmer',
|
||||
'amount' => num(7.0),
|
||||
]),
|
||||
'Dave Lister' => new DibiRow([
|
||||
'Dave Lister' => new Row([
|
||||
'title' => ['Table' => 'Dave Lister'],
|
||||
'name' => 'Dave Lister',
|
||||
'amount' => num(3.0),
|
||||
]),
|
||||
'Kristine Kochanski' => new DibiRow([
|
||||
'Kristine Kochanski' => new Row([
|
||||
'title' => ['Computer' => 'Kristine Kochanski'],
|
||||
'name' => 'Kristine Kochanski',
|
||||
'amount' => num(5.0),
|
||||
@@ -296,32 +297,32 @@ Assert::equal([
|
||||
|
||||
|
||||
Assert::equal([
|
||||
new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
], query($conn)->fetchAssoc('[]'));
|
||||
|
||||
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => new DibiRow([
|
||||
'Arnold Rimmer' => new Row([
|
||||
'title' => [
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
'name' => 'Arnold Rimmer',
|
||||
'amount' => num(7.0),
|
||||
]),
|
||||
'Dave Lister' => new DibiRow([
|
||||
'Dave Lister' => new Row([
|
||||
'title' => [
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
'name' => 'Dave Lister',
|
||||
'amount' => num(3.0),
|
||||
]),
|
||||
'Kristine Kochanski' => new DibiRow([
|
||||
'Kristine Kochanski' => new Row([
|
||||
'title' => [
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
'name' => 'Kristine Kochanski',
|
||||
'amount' => num(5.0),
|
||||
|
@@ -5,7 +5,7 @@ use Tester\Assert;
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
|
||||
// create new substitution :blog: ==> wp_
|
||||
$conn->getSubstitutes()->blog = 'wp_';
|
||||
|
@@ -9,22 +9,22 @@ use Tester\Assert;
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
|
||||
/*Assert::exception(function () use ($conn) {
|
||||
$conn->rollback();
|
||||
}, 'DibiException');
|
||||
}, 'Dibi\Exception');
|
||||
|
||||
Assert::exception(function () use ($conn) {
|
||||
$conn->commit();
|
||||
}, 'DibiException');
|
||||
}, 'Dibi\Exception');
|
||||
|
||||
$conn->begin();
|
||||
Assert::exception(function () use ($conn) {
|
||||
$conn->begin();
|
||||
}, 'DibiException');
|
||||
}, 'Dibi\Exception');
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
use Tester\Assert;
|
||||
use Dibi\Row;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
|
||||
@@ -80,7 +81,7 @@ Assert::same(1, $ds->toDataSource()->count());
|
||||
|
||||
|
||||
Assert::equal([
|
||||
new DibiRow([
|
||||
new Row([
|
||||
'product_id' => 1,
|
||||
]),
|
||||
], iterator_to_array($ds));
|
||||
@@ -117,7 +118,7 @@ FROM (SELECT [title] FROM [products]) t'),
|
||||
(string) $ds
|
||||
);
|
||||
|
||||
Assert::equal(new DibiRow([
|
||||
Assert::equal(new Row([
|
||||
'product_id' => 1,
|
||||
'title' => 'Chair',
|
||||
]), $conn->dataSource('SELECT * FROM products ORDER BY product_id')->fetch());
|
||||
@@ -130,22 +131,22 @@ Assert::same(
|
||||
);
|
||||
|
||||
Assert::equal([
|
||||
1 => new DibiRow([
|
||||
1 => new Row([
|
||||
'product_id' => 1,
|
||||
'title' => 'Chair',
|
||||
]),
|
||||
new DibiRow([
|
||||
new Row([
|
||||
'product_id' => 2,
|
||||
'title' => 'Table',
|
||||
]),
|
||||
new DibiRow([
|
||||
new Row([
|
||||
'product_id' => 3,
|
||||
'title' => 'Computer',
|
||||
]),
|
||||
], $conn->dataSource('SELECT * FROM products ORDER BY product_id')->fetchAssoc('product_id'));
|
||||
|
||||
|
||||
$ds = new DibiDataSource('products', $conn);
|
||||
$ds = new Dibi\DataSource('products', $conn);
|
||||
|
||||
Assert::match(
|
||||
reformat('
|
||||
|
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
|
||||
use Tester\Assert;
|
||||
use Dibi\Fluent;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
|
||||
$fluent = new DibiFluent($conn);
|
||||
$fluent = new Fluent($conn);
|
||||
$fluent->select('*')->from('table')->where('x=1');
|
||||
$dolly = clone $fluent;
|
||||
$dolly->where('y=1');
|
||||
@@ -17,7 +18,7 @@ Assert::same(reformat('SELECT * FROM [table] WHERE x=1'), (string) $fluent);
|
||||
Assert::same(reformat('SELECT * FROM [table] WHERE x=1 AND y=1 FOO'), (string) $dolly);
|
||||
|
||||
|
||||
$fluent = new DibiFluent($conn);
|
||||
$fluent = new Fluent($conn);
|
||||
$fluent->select('id')->from('table')->where('id = %i', 1);
|
||||
$dolly = clone $fluent;
|
||||
$dolly->where('cd = %i', 5);
|
||||
@@ -26,7 +27,7 @@ Assert::same(reformat('SELECT [id] FROM [table] WHERE id = 1'), (string) $fluent
|
||||
Assert::same(reformat('SELECT [id] FROM [table] WHERE id = 1 AND cd = 5'), (string) $dolly);
|
||||
|
||||
|
||||
$fluent = new DibiFluent($conn);
|
||||
$fluent = new Fluent($conn);
|
||||
$fluent->select('*')->from('table');
|
||||
$dolly = clone $fluent;
|
||||
$dolly->removeClause('select')->select('count(*)');
|
||||
|
@@ -5,7 +5,7 @@ use Tester\Assert;
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
|
||||
|
||||
$fluent = $conn->delete('table')->as('bAlias')
|
||||
|
@@ -5,10 +5,11 @@
|
||||
*/
|
||||
|
||||
use Tester\Assert;
|
||||
use Dibi\Row;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
|
||||
@@ -30,9 +31,9 @@ Assert::equal('Chair', $res->fetchSingle());
|
||||
// fetch complete result set
|
||||
$res = $conn->select('*')->from('products')->orderBy('product_id');
|
||||
Assert::equal([
|
||||
new DibiRow(['product_id' => num(1), 'title' => 'Chair']),
|
||||
new DibiRow(['product_id' => num(2), 'title' => 'Table']),
|
||||
new DibiRow(['product_id' => num(3), 'title' => 'Computer']),
|
||||
new Row(['product_id' => num(1), 'title' => 'Chair']),
|
||||
new Row(['product_id' => num(2), 'title' => 'Table']),
|
||||
new Row(['product_id' => num(3), 'title' => 'Computer']),
|
||||
], $res->fetchAll());
|
||||
|
||||
|
||||
@@ -46,14 +47,14 @@ if ($config['system'] !== 'odbc') {
|
||||
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => [
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
'Chair' => new Row(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
'Dave Lister' => [
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
'Table' => new Row(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
'Kristine Kochanski' => [
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
'Computer' => new Row(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
], $res->fetchAssoc('name,title'));
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ use Tester\Assert;
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
|
||||
|
||||
$arr = [
|
||||
|
@@ -5,7 +5,7 @@ use Tester\Assert;
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
|
||||
|
||||
$max = 10;
|
||||
@@ -68,7 +68,7 @@ Assert::same(
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
$fluent->orderBy(DibiFluent::REMOVE);
|
||||
$fluent->orderBy(Dibi\Fluent::REMOVE);
|
||||
|
||||
Assert::same(
|
||||
reformat('SELECT * , [a] , [b] AS [bAlias] , [c], [d], [e] , [d] FROM [anotherTable] AS [anotherAlias] INNER JOIN [table3] ON table.col = table3.col WHERE col > 10 OR col < 5 AND active = 1 AND [col] IN (1, 2, 3)'),
|
||||
|
@@ -5,7 +5,7 @@ use Tester\Assert;
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
|
||||
|
||||
$arr = [
|
||||
|
@@ -76,5 +76,5 @@ $tests = function ($conn) {
|
||||
}
|
||||
};
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$tests($conn);
|
||||
|
@@ -25,7 +25,7 @@ $tests = function ($conn) {
|
||||
Assert::true($conn->query("SELECT 'AA\\BB' LIKE %~like~", 'A\\B')->fetchSingle());
|
||||
};
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->query('SET escape_string_warning = off'); // do not log warnings
|
||||
|
||||
$conn->query('SET standard_conforming_strings = on');
|
||||
|
@@ -12,7 +12,7 @@ if ($config['system'] === 'odbc') {
|
||||
Tester\Environment::skip('Not supported.');
|
||||
}
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
$info = $conn->query('
|
||||
|
@@ -4,15 +4,15 @@ use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
$res = $conn->query('SELECT * FROM [customers]');
|
||||
|
||||
// auto-converts this column to integer
|
||||
$res->setType('customer_id', DibiType::DATETIME, 'H:i j.n.Y');
|
||||
$res->setType('customer_id', Dibi\Type::DATETIME, 'H:i j.n.Y');
|
||||
|
||||
Assert::equal(new DibiRow([
|
||||
'customer_id' => new DibiDateTime('1970-01-01 01:00:01'),
|
||||
Assert::equal(new Dibi\Row([
|
||||
'customer_id' => new Dibi\DateTime('1970-01-01 01:00:01'),
|
||||
'name' => 'Dave Lister',
|
||||
]), $res->fetch());
|
||||
|
@@ -8,7 +8,7 @@ use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
|
||||
|
@@ -7,7 +7,7 @@ require __DIR__ . '/bootstrap.php';
|
||||
|
||||
class TestClass
|
||||
{
|
||||
use DibiStrict;
|
||||
use Dibi\Strict;
|
||||
|
||||
public $public;
|
||||
|
||||
|
@@ -8,8 +8,8 @@ use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$translator = new DibiTranslator($conn);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$translator = new Dibi\Translator($conn);
|
||||
|
||||
$datetime = new DateTime('1978-01-23 00:00:00');
|
||||
|
||||
|
@@ -8,7 +8,7 @@ use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
|
||||
|
||||
// if & end
|
||||
|
@@ -8,7 +8,7 @@ use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
|
||||
|
||||
Assert::same(
|
||||
|
@@ -5,10 +5,11 @@
|
||||
*/
|
||||
|
||||
use Tester\Assert;
|
||||
use Dibi\DateTime;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new DibiConnection($config + ['formatDateTime' => "'Y-m-d H:i:s'", 'formatDate' => "'Y-m-d'"]);
|
||||
$conn = new Dibi\Connection($config + ['formatDateTime' => "'Y-m-d H:i:s'", 'formatDate' => "'Y-m-d'"]);
|
||||
|
||||
|
||||
// dibi detects INSERT or REPLACE command & booleans
|
||||
@@ -76,7 +77,7 @@ Assert::same(
|
||||
// invalid input
|
||||
$e = Assert::exception(function () use ($conn) {
|
||||
$conn->translate('SELECT %s', (object) [123], ', %m', 123);
|
||||
}, 'DibiException', 'SQL translate error');
|
||||
}, 'Dibi\Exception', 'SQL translate error');
|
||||
Assert::same('SELECT **Unexpected type object** , **Unknown or invalid modifier %m**', $e->getSql());
|
||||
|
||||
Assert::same(
|
||||
@@ -148,7 +149,7 @@ Assert::same(
|
||||
if ($config['system'] === 'odbc') {
|
||||
Assert::exception(function () use ($conn) {
|
||||
$conn->translate('SELECT * FROM [products] %lmt %ofs', 2, 1);
|
||||
}, 'DibiException');
|
||||
}, 'Dibi\Exception');
|
||||
} else {
|
||||
// with limit = 2, offset = 1
|
||||
Assert::same(
|
||||
@@ -176,8 +177,8 @@ Assert::same(
|
||||
"INSERT INTO test ([a2], [a4], [b1], [b2], [b3], [b4], [b5], [b6], [b7], [b8], [b9]) VALUES ('1212-09-26 00:00:00', '1969-12-31 22:13:20', '1212-09-26', '1212-09-26 00:00:00', '1969-12-31', '1969-12-31 22:13:20', '1212-09-26 00:00:00', '1212-09-26', '1212-09-26 00:00:00', NULL, NULL)",
|
||||
]),
|
||||
$conn->translate('INSERT INTO test', [
|
||||
'a2' => new DibiDateTime('1212-09-26'),
|
||||
'a4' => new DibiDateTime(-10000),
|
||||
'a2' => new DateTime('1212-09-26'),
|
||||
'a4' => new DateTime(-10000),
|
||||
'b1%d' => '1212-09-26',
|
||||
'b2%t' => '1212-09-26',
|
||||
'b3%d' => -10000,
|
||||
@@ -227,7 +228,7 @@ if ($config['system'] === 'pgsql') {
|
||||
|
||||
$e = Assert::exception(function () use ($conn) {
|
||||
$conn->translate("SELECT '");
|
||||
}, 'DibiException', 'SQL translate error');
|
||||
}, 'Dibi\Exception', 'SQL translate error');
|
||||
Assert::same('SELECT **Alone quote**', $e->getSql());
|
||||
|
||||
Assert::match(
|
||||
@@ -273,7 +274,7 @@ $array3 = [
|
||||
$array4 = [
|
||||
'a' => 12,
|
||||
'b' => NULL,
|
||||
'c' => new DibiDateTime('12.3.2007'),
|
||||
'c' => new DateTime('12.3.2007'),
|
||||
'd' => 'any string',
|
||||
];
|
||||
|
||||
@@ -472,7 +473,7 @@ $e = Assert::exception(function () use ($conn) {
|
||||
'num%i' => ['1', ''],
|
||||
];
|
||||
$conn->translate('INSERT INTO test %m', $array6);
|
||||
}, 'DibiException', 'SQL translate error');
|
||||
}, 'Dibi\Exception', 'SQL translate error');
|
||||
Assert::same('INSERT INTO test **Multi-insert array "num%i" is different.**', $e->getSql());
|
||||
|
||||
$array6 = [
|
||||
|
@@ -37,13 +37,13 @@ if ($config['system'] === 'odbc') {
|
||||
|
||||
|
||||
try {
|
||||
new DibiConnection($config);
|
||||
} catch (DibiNotSupportedException $e) {
|
||||
new Dibi\Connection($config);
|
||||
} catch (Dibi\NotSupportedException $e) {
|
||||
Tester\Environment::skip($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
function test(\Closure $function)
|
||||
function test(Closure $function)
|
||||
{
|
||||
$function();
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ if ($config['system'] === 'odbc' || $config['driver'] === 'pdo') {
|
||||
Tester\Environment::skip('Not supported.');
|
||||
}
|
||||
|
||||
$conn = new DibiConnection($config);
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user