1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-05 21:58:10 +02:00

tests: added new, typo

This commit is contained in:
David Grudl
2015-10-06 15:36:05 +02:00
parent 806ee1ccd1
commit d708ac2aeb
2 changed files with 43 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ use Tracy;
/**
* Dibi panel for Tracy.
*
* @package dibi\nette
*/
class Panel extends \DibiObject implements Tracy\IBarPanel
{

42
tests/dibi/DibiRow.phpt Normal file
View File

@@ -0,0 +1,42 @@
<?php
/**
* @dataProvider ../databases.ini mysqli
*/
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
$conn = new DibiConnection($config);
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
$row = $conn->fetch('SELECT * FROM [products] ORDER BY product_id');
// existing
Assert::same('Chair', $row->title);
Assert::true(isset($row->title));
Assert::same('Chair', $row['title']);
Assert::true(isset($row['title']));
// missing
Assert::error(function () use ($row) {
$x = $row->missing;
}, E_NOTICE, 'Undefined property: DibiRow::$missing');
Assert::error(function () use ($row) {
$x = $row['missing'];
}, E_NOTICE, 'Undefined property: DibiRow::$missing');
Assert::false(isset($row->missing));
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());
// counting
Assert::same(2, count($row));