1
0
mirror of synced 2024-12-14 07:06:04 +03:00

Remove builders from QueryExpressionVisitorTest constructor

This commit is contained in:
Kirill chEbba Chebunin 2012-08-29 15:48:04 +04:00
parent 2aba7fb374
commit a162f00ecc

View File

@ -41,23 +41,6 @@ class QueryExpressionVisitorTest extends \PHPUnit_Framework_TestCase
* @var QueryExpressionVisitor
*/
private $visitor;
/**
* @var CriteriaBuilder
*/
private $criteriaBuilder;
/**
* @var QueryBuilder
*/
private $queryBuilder;
public function __construct($name = NULL, array $data = array(), $dataName = '')
{
$this->criteriaBuilder = new CriteriaBuilder();
$this->queryBuilder = new QueryBuilder();
parent::__construct($name, $data, $dataName);
}
/**
* {@inheritDoc}
@ -84,32 +67,36 @@ class QueryExpressionVisitorTest extends \PHPUnit_Framework_TestCase
public function comparisonData()
{
$cb = new CriteriaBuilder();
$qb = new QueryBuilder();
return array(
array($this->criteriaBuilder->eq('field', 'value'), $this->queryBuilder->eq('field', ':field'), new Parameter('field', 'value')),
array($this->criteriaBuilder->neq('field', 'value'), $this->queryBuilder->neq('field', ':field'), new Parameter('field', 'value')),
array($this->criteriaBuilder->eq('field', null), $this->queryBuilder->isNull('field')),
array($this->criteriaBuilder->neq('field', null), $this->queryBuilder->isNotNull('field')),
array($this->criteriaBuilder->isNull('field'), $this->queryBuilder->isNull('field')),
array($cb->eq('field', 'value'), $qb->eq('field', ':field'), new Parameter('field', 'value')),
array($cb->neq('field', 'value'), $qb->neq('field', ':field'), new Parameter('field', 'value')),
array($cb->eq('field', null), $qb->isNull('field')),
array($cb->neq('field', null), $qb->isNotNull('field')),
array($cb->isNull('field'), $qb->isNull('field')),
array($this->criteriaBuilder->gt('field', 'value'), $this->queryBuilder->gt('field', ':field'), new Parameter('field', 'value')),
array($this->criteriaBuilder->gte('field', 'value'), $this->queryBuilder->gte('field', ':field'), new Parameter('field', 'value')),
array($this->criteriaBuilder->lt('field', 'value'), $this->queryBuilder->lt('field', ':field'), new Parameter('field', 'value')),
array($this->criteriaBuilder->lte('field', 'value'), $this->queryBuilder->lte('field', ':field'), new Parameter('field', 'value')),
array($cb->gt('field', 'value'), $qb->gt('field', ':field'), new Parameter('field', 'value')),
array($cb->gte('field', 'value'), $qb->gte('field', ':field'), new Parameter('field', 'value')),
array($cb->lt('field', 'value'), $qb->lt('field', ':field'), new Parameter('field', 'value')),
array($cb->lte('field', 'value'), $qb->lte('field', ':field'), new Parameter('field', 'value')),
array($this->criteriaBuilder->in('field', array('value')), $this->queryBuilder->in('field', ':field'), new Parameter('field', array('value'))),
array($this->criteriaBuilder->notIn('field', array('value')), $this->queryBuilder->notIn('field', ':field'), new Parameter('field', array('value'))),
array($cb->in('field', array('value')), $qb->in('field', ':field'), new Parameter('field', array('value'))),
array($cb->notIn('field', array('value')), $qb->notIn('field', ':field'), new Parameter('field', array('value'))),
// Test parameter conversion
array($this->criteriaBuilder->eq('object.field', 'value'), $this->queryBuilder->eq('object.field', ':object_field'), new Parameter('object_field', 'value')),
array($cb->eq('object.field', 'value'), $qb->eq('object.field', ':object_field'), new Parameter('object_field', 'value')),
);
}
public function testWalkAndCompositeExpression()
{
$cb = new CriteriaBuilder();
$expr = $this->visitor->walkCompositeExpression(
$this->criteriaBuilder->andX(
$this->criteriaBuilder->eq("foo", 1),
$this->criteriaBuilder->eq("bar", 1)
$cb->andX(
$cb->eq("foo", 1),
$cb->eq("bar", 1)
)
);
@ -119,10 +106,11 @@ class QueryExpressionVisitorTest extends \PHPUnit_Framework_TestCase
public function testWalkOrCompositeExpression()
{
$cb = new CriteriaBuilder();
$expr = $this->visitor->walkCompositeExpression(
$this->criteriaBuilder->orX(
$this->criteriaBuilder->eq("foo", 1),
$this->criteriaBuilder->eq("bar", 1)
$cb->orX(
$cb->eq("foo", 1),
$cb->eq("bar", 1)
)
);