diff options
Diffstat (limited to 'tests/simple_unit')
-rw-r--r-- | tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php | 1 | ||||
-rw-r--r-- | tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php | 17 |
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 |