summaryrefslogtreecommitdiff
path: root/tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php')
-rw-r--r--tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php b/tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php
index 16036b9f..77408631 100644
--- a/tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php
+++ b/tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php
@@ -32,7 +32,7 @@ class Table1 extends MultipleFKSqliteRecord
public $fk3;
public $object1;
- public $object2;
+ //public $object2; //commented out for testing __get/__set
public $object3;
public static $RELATIONS = array
@@ -57,7 +57,7 @@ class Table2 extends MultipleFKSqliteRecord
public $field1;
private $_state1;
- public $state2;
+ //public $state2; //commented out for testing __get/__set
public $state3;
public static $RELATIONS = array
@@ -174,6 +174,19 @@ class MultipleForeignKeyTestCase extends UnitTestCase
$this->assertEqual($obj->parent_category->cat_id, 1);
}
+
+ function testLazyLoadingGetterSetter_hasMany()
+ {
+ $arr = Table2::finder()->findByPk(2);
+
+ $this->assertNotNull($arr->state2); //lazy load
+ $this->assertEqual(count($arr->state2), 1);
+ $this->assertEqual($arr->state2[0]->id, "1");
+ $this->assertNotNull($arr->state2[0]->object2);
+ $this->assertEqual($arr->state2[0]->object2->id, "2");
+
+ $this->assertNotIdentical($arr, $arr->state2[0]->object2);
+ }
}
?> \ No newline at end of file