|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Happyr Doctrine Specification package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Tobias Nyholm <[email protected]> |
|
7
|
|
|
* Kacper Gunia <[email protected]> |
|
8
|
|
|
* Peter Gribanov <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace tests\Happyr\DoctrineSpecification\Logic; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\ORM\Query\Expr; |
|
17
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
18
|
|
|
use Happyr\DoctrineSpecification\Filter\Filter; |
|
19
|
|
|
use Happyr\DoctrineSpecification\Logic\Not; |
|
20
|
|
|
use Happyr\DoctrineSpecification\Specification\Specification; |
|
21
|
|
|
use PhpSpec\ObjectBehavior; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @mixin Not |
|
25
|
|
|
*/ |
|
26
|
|
|
class NotSpec extends ObjectBehavior |
|
27
|
|
|
{ |
|
28
|
|
|
public function let(Filter $filterExpr) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->beConstructedWith($filterExpr, null); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* calls parent. |
|
35
|
|
|
*/ |
|
36
|
|
|
public function it_calls_parent_match(QueryBuilder $qb, Expr $expr, Filter $filterExpr) |
|
37
|
|
|
{ |
|
38
|
|
|
$dqlAlias = 'a'; |
|
39
|
|
|
$expression = 'expression'; |
|
40
|
|
|
$parentExpression = 'foobar'; |
|
41
|
|
|
|
|
42
|
|
|
$qb->expr()->willReturn($expr); |
|
43
|
|
|
$filterExpr->getFilter($qb, $dqlAlias)->willReturn($parentExpression); |
|
44
|
|
|
|
|
45
|
|
|
$expr->not($parentExpression)->willReturn($expression); |
|
46
|
|
|
|
|
47
|
|
|
$this->getFilter($qb, $dqlAlias)->shouldReturn($expression); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* modifies parent query. |
|
52
|
|
|
*/ |
|
53
|
|
|
public function it_modifies_parent_query(QueryBuilder $qb, Specification $spec) |
|
54
|
|
|
{ |
|
55
|
|
|
$this->beConstructedWith($spec, null); |
|
56
|
|
|
|
|
57
|
|
|
$spec->modify($qb, 'a')->shouldBeCalled(); |
|
58
|
|
|
$this->modify($qb, 'a'); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function it_does_not_modify_parent_query(QueryBuilder $qb) |
|
62
|
|
|
{ |
|
63
|
|
|
$this->modify($qb, 'a'); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|