summaryrefslogtreecommitdiff
path: root/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php')
-rw-r--r--tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php b/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php
index 8c39a797..0c1da5d2 100644
--- a/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php
+++ b/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php
@@ -1,6 +1,7 @@
<?php
Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/ItemRecord.php');
abstract class SqliteRecord extends TActiveRecord
{
@@ -153,6 +154,20 @@ class ForeignKeyTestCase extends UnitTestCase
$this->assertEqual($album->cover->content, 'lalala');
}
+
+ function test_self_reference_fk()
+ {
+ $item = ItemRecord::finder()->withRelated_Items()->findByPk(1);
+ $this->assertNotNull($item);
+ $this->assertEqual($item->name, "Professional Work Attire");
+
+ $this->assertEqual(count($item->related_items),2);
+ $this->assertEqual($item->related_items[0]->name, "Nametags");
+ $this->assertEqual($item->related_items[0]->item_id, 2);
+
+ $this->assertEqual($item->related_items[1]->name, "Grooming and Hygiene");
+ $this->assertEqual($item->related_items[1]->item_id, 3);
+ }
}
?> \ No newline at end of file