From a162f00eccb684861dd0acd8d863470eef6923d4 Mon Sep 17 00:00:00 2001 From: Kirill chEbba Chebunin Date: Wed, 29 Aug 2012 15:48:04 +0400 Subject: [PATCH] Remove builders from QueryExpressionVisitorTest constructor --- .../ORM/Query/QueryExpressionVisitorTest.php | 58 ++++++++----------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index c23090c7d..5eaeb7646 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -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) ) );