Merge branch 'feature/#1054-DDC-3161-allow-connection-access-in-filters'
Close #1054
This commit is contained in:
commit
ef113e52ab
@ -133,6 +133,16 @@ abstract class SQLFilter
|
|||||||
return serialize($this->parameters);
|
return serialize($this->parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the database connection used by the entity manager
|
||||||
|
*
|
||||||
|
* @return \Doctrine\DBAL\Connection
|
||||||
|
*/
|
||||||
|
final protected function getConnection()
|
||||||
|
{
|
||||||
|
return $this->em->getConnection();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the SQL query part to add to a query.
|
* Gets the SQL query part to add to a query.
|
||||||
*
|
*
|
||||||
|
@ -243,6 +243,28 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$this->assertEquals("'en'", $filter->getParameter('locale'));
|
$this->assertEquals("'en'", $filter->getParameter('locale'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-3161
|
||||||
|
* @group 1054
|
||||||
|
*/
|
||||||
|
public function testSQLFilterGetConnection()
|
||||||
|
{
|
||||||
|
// Setup mock connection
|
||||||
|
$conn = $this->getMockConnection();
|
||||||
|
|
||||||
|
$em = $this->getMockEntityManager($conn);
|
||||||
|
$em->expects($this->once())
|
||||||
|
->method('getConnection')
|
||||||
|
->will($this->returnValue($conn));
|
||||||
|
|
||||||
|
$filter = new MyLocaleFilter($em);
|
||||||
|
|
||||||
|
$reflMethod = new \ReflectionMethod('Doctrine\ORM\Query\Filter\SQLFilter', 'getConnection');
|
||||||
|
$reflMethod->setAccessible(true);
|
||||||
|
|
||||||
|
$this->assertSame($conn, $reflMethod->invoke($filter));
|
||||||
|
}
|
||||||
|
|
||||||
public function testSQLFilterSetParameterInfersType()
|
public function testSQLFilterSetParameterInfersType()
|
||||||
{
|
{
|
||||||
// Setup mock connection
|
// Setup mock connection
|
||||||
|
Loading…
Reference in New Issue
Block a user