@@ 14-72 (lines=59) @@ | ||
11 | /** |
|
12 | * @mixin Value |
|
13 | */ |
|
14 | class ValueSpec extends ObjectBehavior |
|
15 | { |
|
16 | private $value = 'foo'; |
|
17 | ||
18 | private $valueType = null; |
|
19 | ||
20 | public function let() |
|
21 | { |
|
22 | $this->beConstructedWith($this->value, $this->valueType); |
|
23 | } |
|
24 | ||
25 | public function it_is_a_value() |
|
26 | { |
|
27 | $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Operand\Value'); |
|
28 | } |
|
29 | ||
30 | public function it_is_a_operand() |
|
31 | { |
|
32 | $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Operand\Operand'); |
|
33 | } |
|
34 | ||
35 | public function it_is_transformable(QueryBuilder $qb, ArrayCollection $parameters) |
|
36 | { |
|
37 | $dqlAlias = 'a'; |
|
38 | ||
39 | $qb->getParameters()->willReturn($parameters); |
|
40 | $parameters->count()->willReturn(10); |
|
41 | ||
42 | $qb->setParameter('comparison_10', $this->value, $this->valueType)->shouldBeCalled(); |
|
43 | ||
44 | $this->transform($qb, $dqlAlias)->shouldReturn(':comparison_10'); |
|
45 | } |
|
46 | ||
47 | public function it_is_transformable_dbal_type(QueryBuilder $qb, ArrayCollection $parameters) |
|
48 | { |
|
49 | $valueType = Type::DATE; |
|
50 | $this->beConstructedWith($this->value, $valueType); |
|
51 | ||
52 | $qb->getParameters()->willReturn($parameters); |
|
53 | $parameters->count()->willReturn(10); |
|
54 | ||
55 | $qb->setParameter('comparison_10', $this->value, $valueType)->shouldBeCalled(); |
|
56 | ||
57 | $this->transform($qb, 'a')->shouldReturn(':comparison_10'); |
|
58 | } |
|
59 | ||
60 | public function it_is_transformable_pdo_type(QueryBuilder $qb, ArrayCollection $parameters) |
|
61 | { |
|
62 | $valueType = \PDO::PARAM_INT; |
|
63 | $this->beConstructedWith($this->value, $valueType); |
|
64 | ||
65 | $qb->getParameters()->willReturn($parameters); |
|
66 | $parameters->count()->willReturn(10); |
|
67 | ||
68 | $qb->setParameter('comparison_10', $this->value, $valueType)->shouldBeCalled(); |
|
69 | ||
70 | $this->transform($qb, 'a')->shouldReturn(':comparison_10'); |
|
71 | } |
|
72 | } |
|
73 |
@@ 14-72 (lines=59) @@ | ||
11 | /** |
|
12 | * @mixin Values |
|
13 | */ |
|
14 | class ValuesSpec extends ObjectBehavior |
|
15 | { |
|
16 | private $values = ['foo', 'bar']; |
|
17 | ||
18 | private $valueType = null; |
|
19 | ||
20 | public function let() |
|
21 | { |
|
22 | $this->beConstructedWith($this->values, $this->valueType); |
|
23 | } |
|
24 | ||
25 | public function it_is_a_values() |
|
26 | { |
|
27 | $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Operand\Values'); |
|
28 | } |
|
29 | ||
30 | public function it_is_a_operand() |
|
31 | { |
|
32 | $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Operand\Operand'); |
|
33 | } |
|
34 | ||
35 | public function it_is_transformable(QueryBuilder $qb, ArrayCollection $parameters) |
|
36 | { |
|
37 | $dqlAlias = 'a'; |
|
38 | ||
39 | $qb->getParameters()->willReturn($parameters); |
|
40 | $parameters->count()->willReturn(10); |
|
41 | ||
42 | $qb->setParameter('comparison_10', $this->values, $this->valueType)->shouldBeCalled(); |
|
43 | ||
44 | $this->transform($qb, $dqlAlias)->shouldReturn(':comparison_10'); |
|
45 | } |
|
46 | ||
47 | public function it_is_transformable_dbal_type(QueryBuilder $qb, ArrayCollection $parameters) |
|
48 | { |
|
49 | $valueType = Type::DATE; |
|
50 | $this->beConstructedWith($this->values, $valueType); |
|
51 | ||
52 | $qb->getParameters()->willReturn($parameters); |
|
53 | $parameters->count()->willReturn(10); |
|
54 | ||
55 | $qb->setParameter('comparison_10', $this->values, $valueType)->shouldBeCalled(); |
|
56 | ||
57 | $this->transform($qb, 'a')->shouldReturn(':comparison_10'); |
|
58 | } |
|
59 | ||
60 | public function it_is_transformable_pdo_type(QueryBuilder $qb, ArrayCollection $parameters) |
|
61 | { |
|
62 | $valueType = \PDO::PARAM_INT; |
|
63 | $this->beConstructedWith($this->values, $valueType); |
|
64 | ||
65 | $qb->getParameters()->willReturn($parameters); |
|
66 | $parameters->count()->willReturn(10); |
|
67 | ||
68 | $qb->setParameter('comparison_10', $this->values, $valueType)->shouldBeCalled(); |
|
69 | ||
70 | $this->transform($qb, 'a')->shouldReturn(':comparison_10'); |
|
71 | } |
|
72 | } |
|
73 |