DDC-778 - Fix AbstractQuery::__clone implementation that was wrongly implemented in DDC-770. Added more tests.
This commit is contained in:
parent
0904bc5cc5
commit
0b5c694a7e
@ -583,6 +583,8 @@ abstract class AbstractQuery
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->free();
|
||||
$this->_params = array();
|
||||
$this->_paramTypes = array();
|
||||
$this->_hints = array();
|
||||
}
|
||||
}
|
||||
|
@ -544,4 +544,15 @@ final class Query extends AbstractQuery
|
||||
'&hydrationMode='.$this->_hydrationMode.'DOCTRINE_QUERY_CACHE_SALT'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup Query resource when clone is called.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
parent::__clone();
|
||||
$this->_state = self::STATE_DIRTY;
|
||||
}
|
||||
}
|
@ -44,4 +44,19 @@ class QueryTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
$this->assertEquals(array(), $query->getParameters());
|
||||
}
|
||||
|
||||
public function testClone()
|
||||
{
|
||||
$dql = "select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1";
|
||||
|
||||
$query = $this->_em->createQuery($dql);
|
||||
$query->setParameter(2, 84, \PDO::PARAM_INT);
|
||||
$query->setHint('foo', 'bar');
|
||||
|
||||
$cloned = clone $query;
|
||||
|
||||
$this->assertEquals($dql, $cloned->getDql());
|
||||
$this->assertEquals(array(), $cloned->getParameters());
|
||||
$this->assertFalse($cloned->getHint('foo'));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user