1
0
mirror of synced 2025-02-20 06:03:15 +03:00

DDC-778 - Fix AbstractQuery::__clone implementation that was wrongly implemented in DDC-770. Added more tests.

This commit is contained in:
Benjamin Eberlei 2010-08-30 20:30:11 +02:00
parent 0904bc5cc5
commit 0b5c694a7e
3 changed files with 29 additions and 1 deletions

View File

@ -583,6 +583,8 @@ abstract class AbstractQuery
*/
public function __clone()
{
$this->free();
$this->_params = array();
$this->_paramTypes = array();
$this->_hints = array();
}
}

View File

@ -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;
}
}

View File

@ -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'));
}
}