1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* This file is part of the Happyr Doctrine Specification package. |
6
|
|
|
* |
7
|
|
|
* (c) Tobias Nyholm <[email protected]> |
8
|
|
|
* Kacper Gunia <[email protected]> |
9
|
|
|
* Peter Gribanov <[email protected]> |
10
|
|
|
* |
11
|
|
|
* For the full copyright and license information, please view the LICENSE |
12
|
|
|
* file that was distributed with this source code. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace tests\Happyr\DoctrineSpecification\Query; |
16
|
|
|
|
17
|
|
|
use Doctrine\ORM\QueryBuilder; |
18
|
|
|
use Happyr\DoctrineSpecification\Operand\Field; |
19
|
|
|
use Happyr\DoctrineSpecification\Query\AddSelect; |
20
|
|
|
use Happyr\DoctrineSpecification\Query\QueryModifier; |
21
|
|
|
use PhpSpec\ObjectBehavior; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @mixin AddSelect |
25
|
|
|
*/ |
26
|
|
|
class AddSelectSpec extends ObjectBehavior |
27
|
|
|
{ |
28
|
|
|
public function let() |
29
|
|
|
{ |
30
|
|
|
$this->beConstructedWith('foo'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function it_is_a_add_select() |
34
|
|
|
{ |
35
|
|
|
$this->shouldBeAnInstanceOf(AddSelect::class); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function it_is_a_specification() |
39
|
|
|
{ |
40
|
|
|
$this->shouldHaveType(QueryModifier::class); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function it_add_select_single_filed(QueryBuilder $qb) |
44
|
|
|
{ |
45
|
|
|
$qb->addSelect(['a.foo'])->shouldBeCalled(); |
46
|
|
|
$this->modify($qb, 'a'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function it_add_select_several_fields(QueryBuilder $qb) |
50
|
|
|
{ |
51
|
|
|
$this->beConstructedWith('foo', 'bar'); |
52
|
|
|
$qb->addSelect(['b.foo', 'b.bar'])->shouldBeCalled(); |
53
|
|
|
$this->modify($qb, 'b'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function it_add_select_operand(QueryBuilder $qb) |
57
|
|
|
{ |
58
|
|
|
$this->beConstructedWith('foo', new Field('bar')); |
59
|
|
|
$qb->addSelect(['b.foo', 'b.bar'])->shouldBeCalled(); |
60
|
|
|
$this->modify($qb, 'b'); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|