diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/lib/Doctrine/ORM/Query/FilterCollection.php index 61647ba33..02100a307 100644 --- a/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/lib/Doctrine/ORM/Query/FilterCollection.php @@ -163,6 +163,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 55b365e4f..7e2d59588 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -172,6 +172,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