From f1809ce180b4abd0841eda7fadb90269be1ccebe Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 23 Jan 2011 16:47:07 +0100 Subject: [PATCH] DDC-968 - Add AbstractQuery::getHints() method --- lib/Doctrine/ORM/AbstractQuery.php | 10 ++++++++++ tests/Doctrine/Tests/ORM/Query/QueryTest.php | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index dd9d1c81a..3de3ede6b 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -458,6 +458,16 @@ abstract class AbstractQuery return isset($this->_hints[$name]) ? $this->_hints[$name] : false; } + /** + * Return the key value map of query hints that are currently set. + * + * @return array + */ + public function getHints() + { + return $this->_hints; + } + /** * Executes the query and returns an IterableResult that can be used to incrementally * iterate over the result. diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 98458c6bd..c5f36f387 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -86,4 +86,17 @@ class QueryTest extends \Doctrine\Tests\OrmTestCase $this->assertSame($q2, $q); } + + /** + * @group DDC-968 + */ + public function testHints() + { + $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); + $q->setHint('foo', 'bar')->setHint('bar', 'baz'); + + $this->assertEquals('bar', $q->getHint('foo')); + $this->assertEquals('baz', $q->getHint('bar')); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $q->getHints()); + } } \ No newline at end of file