summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorwei <>2007-11-01 04:20:14 +0000
committerwei <>2007-11-01 04:20:14 +0000
commitf6fac5cc2f679a6e93a39ea4127f58e438a583c5 (patch)
tree3098dc90cdde01ba6cece67c0b2c979de6ffa2d2 /tests
parent6a0174448c793cb071e1e6d12f3da3a65eeb4e15 (diff)
Refactored ActiveRecord: removed object registry, fixed relationship casing problems.
Diffstat (limited to 'tests')
-rw-r--r--tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php1
-rw-r--r--tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php17
2 files changed, 15 insertions, 3 deletions
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