Skip to content

Commit

Permalink
[MODM-33] Adding test
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed Aug 2, 2010
1 parent 44bf780 commit af9aa0f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Expand Up @@ -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);
}
}
15 changes: 13 additions & 2 deletions tests/Documents/BaseDocument.php
Expand Up @@ -2,9 +2,14 @@

namespace Documents;

/** @MappedSuperClass */
class BaseDocument
/**
* @MappedSuperClass
* @HasLifecycleCallbacks
*/
abstract class BaseDocument
{
public $persisted = false;

/** @String */
protected $inheritedProperty;

Expand All @@ -17,4 +22,10 @@ public function getInheritedProperty()
{
return $this->inheritedProperty;
}

/** @PrePersist */
public function prePersist()
{
$this->persisted = true;
}
}

0 comments on commit af9aa0f

Please sign in to comment.