mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 13:47:33 +02:00
tests: added new, typo
This commit is contained in:
@@ -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
42
tests/dibi/DibiRow.phpt
Normal 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));
|
Reference in New Issue
Block a user