From 93b20427c997782e0e6fea85c5b1479f321d62a0 Mon Sep 17 00:00:00 2001 From: beberlei Date: Fri, 6 Nov 2009 17:03:59 +0000 Subject: [PATCH] [2.0] Fix Tab Formating in ParserResult class, added doc-comments and fixed a missing variable initialization error for certain query special cases. --- lib/Doctrine/ORM/Query/ParserResult.php | 28 ++++++++--- tests/Doctrine/Tests/ORM/Query/AllTests.php | 1 + .../Tests/ORM/Query/ParserResultTest.php | 48 +++++++++++++++++++ 3 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 tests/Doctrine/Tests/ORM/Query/ParserResultTest.php diff --git a/lib/Doctrine/ORM/Query/ParserResult.php b/lib/Doctrine/ORM/Query/ParserResult.php index f242616de..42aecc184 100644 --- a/lib/Doctrine/ORM/Query/ParserResult.php +++ b/lib/Doctrine/ORM/Query/ParserResult.php @@ -35,12 +35,26 @@ namespace Doctrine\ORM\Query; */ class ParserResult { - /** The SQL executor used for executing the SQL. */ - private $_sqlExecutor; - /** The ResultSetMapping that describes how to map the SQL result set. */ + /** + * The SQL executor used for executing the SQL. + * + * @var \Doctrine\ORM\Query\Exec\AbstractSqlExecutor + */ + private $_sqlExecutor; + + /** + * The ResultSetMapping that describes how to map the SQL result set. + * + * @var \Doctrine\ORM\Query\ResultSetMapping + */ private $_resultSetMapping; - /** The mappings of DQL parameter names/positions to SQL parameter positions. */ - private $_parameterMappings; + + /** + * The mappings of DQL parameter names/positions to SQL parameter positions. + * + * @var array + */ + private $_parameterMappings = array(); /** * Initializes a new instance of the ParserResult class. @@ -75,7 +89,7 @@ class ParserResult /** * Sets the SQL executor that should be used for this ParserResult. * - * @param AbstractExecutor $executor + * @param \Doctrine\ORM\Query\Exec\AbstractSqlExecutor $executor */ public function setSqlExecutor($executor) { @@ -85,7 +99,7 @@ class ParserResult /** * Gets the SQL executor used by this ParserResult. * - * @return AbstractExecutor + * @return \Doctrine\ORM\Query\Exec\AbstractSqlExecutor */ public function getSqlExecutor() { diff --git a/tests/Doctrine/Tests/ORM/Query/AllTests.php b/tests/Doctrine/Tests/ORM/Query/AllTests.php index de4eb9c8c..02ab07365 100644 --- a/tests/Doctrine/Tests/ORM/Query/AllTests.php +++ b/tests/Doctrine/Tests/ORM/Query/AllTests.php @@ -25,6 +25,7 @@ class AllTests $suite->addTestSuite('Doctrine\Tests\ORM\Query\DeleteSqlGenerationTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Query\UpdateSqlGenerationTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Query\ExprTest'); + $suite->addTestSuite('Doctrine\Tests\ORM\Query\ParserResultTest'); return $suite; } diff --git a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php new file mode 100644 index 000000000..d9449720d --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php @@ -0,0 +1,48 @@ +result = new ParserResult(); + } + + public function testGetRsm() + { + $this->assertType( + 'Doctrine\ORM\Query\ResultSetMapping', + $this->result->getResultSetMapping() + ); + } + + public function testSetGetSqlExecutor() + { + $this->assertNull($this->result->getSqlExecutor()); + + $executor = $this->getMock('Doctrine\ORM\Query\Exec\AbstractSqlExecutor', array('execute')); + $this->result->setSqlExecutor($executor); + $this->assertSame($executor, $this->result->getSqlExecutor()); + } + + public function testGetSqlParameterPosition() + { + $this->result->addParameterMapping(1, 1); + $this->result->addParameterMapping(1, 2); + $this->assertEquals(array(1, 2), $this->result->getSqlParameterPositions(1)); + } + + public function testGetParameterMappings() + { + $this->assertType('array', $this->result->getParameterMappings()); + + $this->result->addParameterMapping(1, 1); + $this->result->addParameterMapping(1, 2); + $this->assertEquals(array(1 => array(1, 2)), $this->result->getParameterMappings()); + } +} \ No newline at end of file