From f6fac5cc2f679a6e93a39ea4127f58e438a583c5 Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 1 Nov 2007 04:20:14 +0000 Subject: Refactored ActiveRecord: removed object registry, fixed relationship casing problems. --- tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php | 1 - .../ActiveRecord/MultipleForeignKeyTestCase.php | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php b/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php index 2e4bee2d..d8017aeb 100644 --- a/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php +++ b/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php @@ -159,7 +159,6 @@ class ForeignKeyTestCase extends UnitTestCase function test_self_reference_fk() { $item = ItemRecord::finder()->withRelated_Items()->findByPk(1); - $this->assertNotNull($item); $this->assertEqual($item->name, "Professional Work Attire"); 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 -- cgit v1.2.3