1
0
mirror of synced 2025-02-09 00:39:25 +03:00

DDC-2931 - adding test that verifies that fetch-joined entities get refreshed with hints

This commit is contained in:
Marco Pivetta 2014-02-01 01:05:34 +01:00 committed by Benjamin Eberlei
parent c204e6c6a1
commit b596bbb29f

View File

@ -2,6 +2,8 @@
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\Query;
require_once __DIR__ . '/../../../TestInit.php';
/**
@ -24,9 +26,9 @@ class DDC2931Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function testIssue()
{
$first = new DDC2931User();
$first = new DDC2931User();
$second = new DDC2931User();
$third = new DDC2931User();
$third = new DDC2931User();
$second->parent = $first;
$third->parent = $second;
@ -42,6 +44,45 @@ class DDC2931Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertSame(2, $second->getRank());
}
public function testFetchJoinedEntitiesCanBeRefreshed()
{
$first = new DDC2931User();
$second = new DDC2931User();
$third = new DDC2931User();
$second->parent = $first;
$third->parent = $second;
$first->value = 1;
$second->value = 2;
$third->value = 3;
$this->_em->persist($first);
$this->_em->persist($second);
$this->_em->persist($third);
$this->_em->flush();
$first->value = 4;
$second->value = 5;
$third->value = 6;
$refreshedSecond = $this
->_em
->createQuery(
'SELECT e, p, c FROM '
. __NAMESPACE__ . '\\DDC2931User e LEFT JOIN e.parent p LEFT JOIN e.child c WHERE e = :id'
)
->setParameter('id', $second)
->setHint(Query::HINT_REFRESH, true)
->getResult();
$this->assertCount(1, $refreshedSecond);
$this->assertSame(1, $first->value);
$this->assertSame(2, $second->value);
$this->assertSame(3, $third->value);
}
}
@ -58,6 +99,9 @@ class DDC2931User
/** @OneToOne(targetEntity="DDC2931User", mappedBy="parent") */
public $child;
/** @Column(type="integer") */
public $value = 0;
/**
* Return Rank recursively
* My rank is 1 + rank of my parent