From d708ac2aeb8e124d4100620bb620bbe5ce827c98 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 6 Oct 2015 15:36:05 +0200 Subject: [PATCH] tests: added new, typo --- dibi/bridges/Tracy/Panel.php | 2 +- tests/dibi/DibiRow.phpt | 42 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/dibi/DibiRow.phpt diff --git a/dibi/bridges/Tracy/Panel.php b/dibi/bridges/Tracy/Panel.php index d01d353f..efaccbda 100644 --- a/dibi/bridges/Tracy/Panel.php +++ b/dibi/bridges/Tracy/Panel.php @@ -13,7 +13,7 @@ use Tracy; /** * Dibi panel for Tracy. - * + * @package dibi\nette */ class Panel extends \DibiObject implements Tracy\IBarPanel { diff --git a/tests/dibi/DibiRow.phpt b/tests/dibi/DibiRow.phpt new file mode 100644 index 00000000..365e4450 --- /dev/null +++ b/tests/dibi/DibiRow.phpt @@ -0,0 +1,42 @@ +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));