diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/InheritanceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/InheritanceTest.php index 7a74341815..1d449e4f82 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/InheritanceTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/InheritanceTest.php @@ -68,4 +68,13 @@ public function testSingleCollectionInhertiance() $document = $this->dm->findOne('Documents\SubProject', array('name' => 'Sub Project')); $this->assertInstanceOf('Documents\SubProject', $document); } + + public function testPrePersistIsCalledFromMappedSuperClass() + { + $user = new \Documents\User(); + $user->setUsername('test'); + $this->dm->persist($user); + $this->dm->flush(); + $this->assertTrue($user->persisted); + } } \ No newline at end of file diff --git a/tests/Documents/BaseDocument.php b/tests/Documents/BaseDocument.php index 75fb90b5de..8592358636 100644 --- a/tests/Documents/BaseDocument.php +++ b/tests/Documents/BaseDocument.php @@ -2,9 +2,14 @@ namespace Documents; -/** @MappedSuperClass */ -class BaseDocument +/** + * @MappedSuperClass + * @HasLifecycleCallbacks + */ +abstract class BaseDocument { + public $persisted = false; + /** @String */ protected $inheritedProperty; @@ -17,4 +22,10 @@ public function getInheritedProperty() { return $this->inheritedProperty; } + + /** @PrePersist */ + public function prePersist() + { + $this->persisted = true; + } } \ No newline at end of file