Skip to content

Commit

Permalink
[MODM-46] Fixing issue with @AlsoLoad extending the @field annotation…
Browse files Browse the repository at this point in the history
… when it should not
  • Loading branch information
jwage committed Aug 17, 2010
1 parent 78fefc3 commit 166ca49
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ final class ReferenceMany extends Field
public $strategy = 'pushPull'; // pushPull, set
}
final class NotSaved extends Field {}
final class AlsoLoad extends Field {
final class AlsoLoad extends Annotation {
public $name;
}
final class ChangeTrackingPolicy extends Annotation {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ class MODM45Test extends \Doctrine\ODM\MongoDB\Tests\BaseTest
{
public function testTest()
{
$a = new a();
$a->setB(new b());
$a = new MODM45A();
$a->setB(new MODM45B());

$this->dm->persist($a);
$this->dm->flush();
$this->dm->clear();

$a = $this->dm->loadByID(__NAMESPACE__.'\a', $a->getId());
$a = $this->dm->loadByID(__NAMESPACE__.'\MODM45A', $a->getId());
$c = (null !== $a->getB());
$this->assertTrue($c); // returns false, while expecting true
}
}

/** @Document(collection="modm45_test") */
class a
class MODM45A
{
/** @Id */
protected $id;

/** @String */
protected $tmp = 'WorkaroundToBeSaved';

/** @EmbedOne(targetDocument="b", cascade="all") */
/** @EmbedOne(targetDocument="MODM45B", cascade="all") */
protected $b;

function getId() {return $this->id;}
Expand All @@ -39,7 +39,7 @@ function setB($b) {$this->b = $b;}
}

/** @EmbeddedDocument */
class b
class MODM45B
{
/** @String */
protected $val;
Expand Down
38 changes: 38 additions & 0 deletions tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM46Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket;

require_once __DIR__ . '/../../../../../../TestInit.php';

class MODM46Test extends \Doctrine\ODM\MongoDB\Tests\BaseTest
{
public function testTest()
{
$this->dm->getMongo()->modm46_test->a->insert(array(
'c' => array('tmp' => 'tmp')
));

$a = $this->dm->findOne(__NAMESPACE__.'\MODM46A');
$this->assertTrue(isset($a->b));
$this->assertEquals('tmp', $a->b->tmp);
}
}

/** @Document(db="modm46_test", collection="a") */
class MODM46A
{
/** @Id */
public $id;

/**
* @EmbedOne(targetDocument="MODM46AB")
* @AlsoLoad("c")
*/
public $b;
}

/** @EmbeddedDocument */
class MODM46AB
{
public $tmp = 'tmp';
}
1 change: 1 addition & 0 deletions tests/Documents/Functional/AlsoLoad.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class AlsoLoad
public $id;

/**
* @String
* @AlsoLoad({"bar", "zip"})
*/
public $foo;
Expand Down

0 comments on commit 166ca49

Please sign in to comment.