1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-23 18:33:45 +01:00
php-dibi/tests/dibi/Result.meta.phpt

64 lines
1.6 KiB
PHP
Raw Normal View History

2015-01-12 05:33:41 +01:00
<?php
/**
* @dataProvider ../databases.ini !=odbc, !=sqlsrv
2015-01-12 05:33:41 +01:00
*/
2017-06-09 22:20:47 +02:00
declare(strict_types=1);
2015-01-12 05:33:41 +01:00
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
$conn = new Dibi\Connection($config);
2015-01-12 05:33:41 +01:00
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
2018-05-04 22:32:45 +02:00
$res = $conn->query('
SELECT products.product_id, orders.order_id, customers.name, products.product_id + 1 AS [xXx]
FROM ([products]
INNER JOIN [orders] ON [products.product_id] = [orders.product_id])
INNER JOIN [customers] ON [orders.customer_id] = [customers.customer_id]
2018-05-04 22:32:45 +02:00
');
$info = $res->getInfo();
Assert::same(4, $res->getColumnCount());
2015-01-12 05:33:41 +01:00
Assert::same(
['product_id', 'order_id', 'name', 'xXx'],
2015-01-12 05:33:41 +01:00
$info->getColumnNames()
);
if (!in_array($config['driver'], ['sqlite', 'pdo', 'sqlsrv'], true)) {
2015-01-12 05:33:41 +01:00
Assert::same(
['products.product_id', 'orders.order_id', 'customers.name', 'xXx'],
$info->getColumnNames(true)
2015-01-12 05:33:41 +01:00
);
}
$columns = $info->getColumns();
2015-10-06 13:14:01 +02:00
Assert::same('product_id', $columns[0]->getName());
if (!in_array($config['driver'], ['sqlite', 'pdo', 'sqlsrv'], true)) {
2015-10-06 13:14:01 +02:00
Assert::same('products', $columns[0]->getTableName());
2015-01-12 05:33:41 +01:00
}
Assert::null($columns[0]->getVendorInfo('xxx'));
2017-07-11 12:29:13 +02:00
if (!in_array($config['system'], ['sqlite', 'sqlsrv'], true)) {
2015-10-06 13:14:01 +02:00
Assert::same('i', $columns[0]->getType());
2015-01-12 05:33:41 +01:00
}
2018-04-17 14:32:02 +02:00
Assert::false($columns[0]->isNullable());
2015-01-12 05:33:41 +01:00
Assert::same('xXx', $columns[3]->getName());
2015-10-06 13:14:01 +02:00
Assert::null($columns[3]->getTableName());
2017-07-11 12:29:13 +02:00
if (!in_array($config['system'], ['sqlite', 'sqlsrv'], true)) {
2015-10-06 13:14:01 +02:00
Assert::same('i', $columns[0]->getType());
2015-01-12 05:33:41 +01:00
}
2018-04-17 14:32:02 +02:00
Assert::false($columns[3]->isNullable());
Assert::same('xXx', $info->getColumn('xxx')->getName());
Assert::same('xXx', $info->getColumn('xXx')->getName());