Skip to content

Commit

Permalink
Remove builders from QueryExpressionVisitorTest constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
chEbba committed Aug 29, 2012
1 parent 2aba7fb commit a162f00
Showing 1 changed file with 23 additions and 35 deletions.
58 changes: 23 additions & 35 deletions tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -84,32 +67,36 @@ public function testWalkComparison(CriteriaComparison $criteriaExpr, $queryExpr,

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)
)
);

Expand All @@ -119,10 +106,11 @@ public function testWalkAndCompositeExpression()

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)
)
);

Expand Down

0 comments on commit a162f00

Please sign in to comment.