function it_composes_and_child_with_expression(QueryBuilder $qb, Expr $expression, Specification $specificationA, Specification $specificationB, $x, $y) { $dqlAlias = 'a'; $specificationA->getFilter($qb, $dqlAlias)->willReturn($x); $specificationB->getFilter($qb, $dqlAlias)->willReturn($y); $qb->expr()->willReturn($expression); $expression->{self::EXPRESSION}($x, $y)->shouldBeCalled(); $this->getFilter($qb, $dqlAlias); }
/** * Prepare a Query with a Specification. * * @param Specification $specification * @param Result\ResultModifier $modifier * * @return \Doctrine\ORM\Query */ public function getQuery(Specification $specification, Result\ResultModifier $modifier = null) { $alias = $this->alias; $qb = $this->createQueryBuilder($alias); $specification->modify($qb, $alias); $query = $qb->where($specification->getFilter($qb, $alias))->getQuery(); if ($modifier !== null) { $modifier->modify($query); return $query; } return $query; }
private function prepareSpecificationStub(Specification $specification, QueryBuilder $qb) { $specification->getFilter($qb, $this->alias)->willReturn($this->expression); }
private function prepareStubs(Specification $specification, EntityManager $entityManager, QueryBuilder $qb, AbstractQuery $query) { $entityManager->createQueryBuilder()->willReturn($qb); $specification->getFilter($qb, $this->alias)->willReturn($this->expression); $qb->from(Argument::any(), $this->alias, null)->willReturn($qb); $qb->select($this->alias)->willReturn($qb); $qb->where($this->expression)->willReturn($qb); $qb->getQuery()->willReturn($query); }