From cfd1b07ffe9a8cc45790616ac6714738f1bf551c Mon Sep 17 00:00:00 2001 From: nemekzg Date: Thu, 10 Jan 2013 16:52:19 +0100 Subject: [PATCH] Fix for DDC-2203 --- lib/Doctrine/ORM/Query/FilterCollection.php | 12 +++++++++++ .../Tests/ORM/Functional/SQLFilterTest.php | 20 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/lib/Doctrine/ORM/Query/FilterCollection.php index 64f425387..860a0611d 100644 --- a/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/lib/Doctrine/ORM/Query/FilterCollection.php @@ -160,6 +160,18 @@ class FilterCollection return $this->enabledFilters[$name]; } + /** + * Checks if a filter is enabled. + * + * @param string $name Name of the filter. + * + * @return boolean True if the filter is enabled, false otherwise. + */ + public function isEnabled($name) + { + return isset($this->enabledFilters[$name]); + } + /** * @return boolean True, if the filter collection is clean. */ diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index 82c240951..2aed6e394 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -156,6 +156,26 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertTrue($exceptionThrown); } + /** + * @group DDC-2203 + */ + public function testEntityManagerIsFilterEnabled() + { + $em = $this->_getEntityManager(); + $this->configureFilters($em); + + // Check for an enabled filter + $em->getFilters()->enable("locale"); + $this->assertTrue($em->getFilters()->isEnabled("locale")); + + // Check for a disabled filter + $em->getFilters()->disable("locale"); + $this->assertFalse($em->getFilters()->isEnabled("locale")); + + // Check a non-existing filter + $this->assertFalse($em->getFilters()->isEnabled("foo_filter")); + } + protected function configureFilters($em) { // Add filters to the configuration of the EM