Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MODM-48] Fixed issue with inserting and updating documents with empt…
…y instances of embedded documents.
- Loading branch information
Showing
3 changed files
with
82 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM48Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket; | ||
|
||
require_once __DIR__ . '/../../../../../../TestInit.php'; | ||
|
||
class MODM48Test extends \Doctrine\ODM\MongoDB\Tests\BaseTest | ||
{ | ||
public function testTest() | ||
{ | ||
$a = new MODM48A(); | ||
$a->b = new MODM48B(); | ||
$this->dm->persist($a); | ||
$this->dm->flush(); | ||
$this->dm->clear(); | ||
|
||
$a = $this->dm->findOne(__NAMESPACE__.'\MODM48A'); | ||
$this->assertNotNull($a); | ||
|
||
$a->getB()->setVal('test'); | ||
|
||
$this->dm->flush(array('safe' => true)); | ||
$this->dm->clear(); | ||
|
||
$a = $this->dm->findOne(__NAMESPACE__.'\MODM48A'); | ||
$this->assertEquals('test', $a->getB()->getVal()); | ||
} | ||
} | ||
|
||
/** @Document(db="modm48_tests", collection="a") */ | ||
class MODM48A | ||
{ | ||
/** @Id */ | ||
public $id; | ||
|
||
/** @EmbedOne(targetDocument="MODM48B", cascade="all") */ | ||
public $b; | ||
|
||
function getId() {return $this->id;} | ||
function getB() {return $this->b;} | ||
function setB($b) {$this->b = $b;} | ||
} | ||
|
||
/** @EmbeddedDocument */ | ||
class MODM48B | ||
{ | ||
/** @String */ | ||
public $val; | ||
|
||
function setVal($val) {$this->val = $val;} | ||
function getVal() {return $this->val;} | ||
} |