diff --git a/doc/ChangeLog b/doc/ChangeLog index cf919d7004..5407f828ee 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2011-11-21 Alexey S. Denisov, Evgeny V. Kokovikhin + + * meta/types/ObjectType.class.php, test/misc/DAOTest.class.php: changed logic + for getObjectId method of lazy encapsulant; test for lazy logic added + 2011-11-29 Igor V. Gulyaev * test/main/ViewTest.class.php: added View test diff --git a/meta/types/ObjectType.class.php b/meta/types/ObjectType.class.php index a1995659f7..525c77f407 100644 --- a/meta/types/ObjectType.class.php +++ b/meta/types/ObjectType.class.php @@ -121,7 +121,9 @@ public function {$methodName}() public function {$methodName}Id() { - return \$this->{$name}Id; + return \$this->{$name} + ? \$this->{$name}->getId() + : \$this->{$name}Id; } EOT; diff --git a/test/misc/DAOTest.class.php b/test/misc/DAOTest.class.php index 04c2680814..14f8dacb8a 100644 --- a/test/misc/DAOTest.class.php +++ b/test/misc/DAOTest.class.php @@ -826,6 +826,30 @@ public function testIpRangeProperty() $this->drop(); } + public function testLazy() + { + $this->create(); + + $parent = TestParentObject::create(); + $child = TestChildObject::create()->setParent($parent); + + $parent->dao()->add($parent); + + $child->dao()->add($child); + + $this->assertEquals( + $parent->getId(), + Criteria::create(TestChildObject::dao())-> + setProjection( + Projection::property('parent.id', 'parentId') + )-> + add(Expression::eq('id', $child->getId()))-> + getCustom('parentId') + ); + + $this->drop(); + } + protected function getSome() { for ($i = 1; $i < 3; ++$i) {