Skip to content

Commit

Permalink
Merge branch 'master' of github.com:doctrine/mongodb-odm
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed Jun 15, 2012
2 parents 496b944 + 1dd4c1e commit f7fc3fe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,5 @@ final class PostRemove extends Annotation {}
final class PreLoad extends Annotation {}
/** @Annotation */
final class PostLoad extends Annotation {}
/** @Annotation */
final class PreFlush extends Annotation {}
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ public function isNullable($fieldName)
*/
public function hasDiscriminator()
{
return $this->discriminatorField && $this->discriminatorValue ? true : false;
return isset($this->discriminatorField) && isset($this->discriminatorValue) ? true : false;
}

/**
Expand Down
18 changes: 18 additions & 0 deletions tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public function testPreUpdate()
$this->assertTrue($user->postUpdate);
$this->assertTrue($user->profile->postUpdate);
}

public function testPreFlush()
{
$user = $this->createUser();
$user->name = 'jwage';
$user->profile->name = 'Jon Doe';
$this->dm->flush();

$this->assertTrue($user->preFlush);
$this->assertTrue($user->profile->preFlush);
}

public function testPreLoadAndPostLoad()
{
Expand Down Expand Up @@ -228,6 +239,7 @@ abstract class BaseDocument
public $postRemove = false;
public $preLoad = false;
public $postLoad = false;
public $preFlush = false;

/** @ODM\PrePersist */
public function prePersist()
Expand Down Expand Up @@ -278,4 +290,10 @@ public function postLoad()
{
$this->postLoad = true;
}

/** @ODM\PreFlush */
public function preFlush()
{
$this->preFlush = true;
}
}

0 comments on commit f7fc3fe

Please sign in to comment.