Permalink
Browse files

[MODM-46] Fixing issue with @AlsoLoad extending the @Field annotation…

… when it should not
  • Loading branch information...
jwage committed Aug 17, 2010
1 parent 78fefc3 commit 166ca49c13c8e3132b85383e4c55f0a09ce0d2b1
@@ -182,7 +182,7 @@ class Field extends Annotation
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 {}
@@ -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;}
@@ -39,7 +39,7 @@ function setB($b) {$this->b = $b;}
}
/** @EmbeddedDocument */
-class b
+class MODM45B
{
/** @String */
protected $val;
@@ -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';
+}
@@ -9,6 +9,7 @@ class AlsoLoad
public $id;
/**
+ * @String
* @AlsoLoad({"bar", "zip"})
*/
public $foo;

0 comments on commit 166ca49

Please sign in to comment.