@@ 48-62 (lines=15) @@ | ||
45 | $this->match($specification); |
|
46 | } |
|
47 | ||
48 | public function it_should_apply_filter( |
|
49 | Filter $specification, |
|
50 | EntityManager $entityManager, |
|
51 | QueryBuilder $qb, |
|
52 | AbstractQuery $query |
|
53 | ) { |
|
54 | $this->prepareEntityManagerStub($entityManager, $qb); |
|
55 | $this->prepareQueryBuilderStub($qb, $query); |
|
56 | $specification->getFilter($qb, $this->alias)->willReturn($this->expression); |
|
57 | ||
58 | $qb->andWhere($this->expression)->willReturn($qb); |
|
59 | $qb->where()->shouldNotBeCalled(); |
|
60 | ||
61 | $this->match($specification); |
|
62 | } |
|
63 | ||
64 | public function it_should_skip_apply_empty_specification( |
|
65 | EntityManager $entityManager, |
|
@@ 215-229 (lines=15) @@ | ||
212 | $this->shouldThrow('Happyr\DoctrineSpecification\Exception\UnexpectedResultException')->duringMatchOneOrNullResult($specification); |
|
213 | } |
|
214 | ||
215 | public function it_matches_a_specification_with_result_modifier( |
|
216 | Specification $specification, |
|
217 | EntityManager $entityManager, |
|
218 | QueryBuilder $qb, |
|
219 | AbstractQuery $query, |
|
220 | ResultModifier $modifier |
|
221 | ) { |
|
222 | $this->prepareStubs($specification, $entityManager, $qb, $query); |
|
223 | $query->execute()->willReturn($this->result); |
|
224 | ||
225 | $specification->modify($qb, $this->alias)->shouldBeCalled(); |
|
226 | $modifier->modify($query)->shouldBeCalled(); |
|
227 | ||
228 | $this->match($specification, $modifier)->shouldReturn($this->result); |
|
229 | } |
|
230 | ||
231 | private function prepareStubs(Specification $specification, EntityManager $entityManager, QueryBuilder $qb, AbstractQuery $query) |
|
232 | { |