Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DDC-770 - Cleanup Query instance when its cloned
- Loading branch information
Showing
4 changed files
with
64 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\ORM\Query; | ||
|
||
require_once __DIR__ . '/../../TestInit.php'; | ||
|
||
class QueryTest extends \Doctrine\Tests\OrmTestCase | ||
{ | ||
protected $_em = null; | ||
|
||
protected function setUp() | ||
{ | ||
$this->_em = $this->_getTestEntityManager(); | ||
} | ||
|
||
/** | ||
* @expectedException Doctrine\ORM\Query\QueryException | ||
*/ | ||
public function testParameterIndexZeroThrowsException() | ||
{ | ||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); | ||
$query->execute(array(42)); // same as array(0 => 42), 0 is invalid parameter position | ||
} | ||
|
||
public function testGetParameters() | ||
{ | ||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); | ||
$this->assertEquals(array(), $query->getParameters()); | ||
} | ||
|
||
public function testGetParameters_HasSomeAlready() | ||
{ | ||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); | ||
$query->setParameter(2, 84); | ||
$this->assertEquals(array(2 => 84), $query->getParameters()); | ||
} | ||
|
||
public function testFree() | ||
{ | ||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); | ||
$query->setParameter(2, 84, \PDO::PARAM_INT); | ||
|
||
$query->free(); | ||
|
||
$this->assertEquals(array(), $query->getParameters()); | ||
} | ||
} |