ValuesSpec::it_is_a_values()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
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\Operand;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\DBAL\Types\Type;
18
use Doctrine\ORM\QueryBuilder;
19
use Happyr\DoctrineSpecification\Operand\Operand;
20
use Happyr\DoctrineSpecification\Operand\Values;
21
use PhpSpec\ObjectBehavior;
22
23
/**
24
 * @mixin Values
25
 */
26 View Code Duplication
class ValuesSpec extends ObjectBehavior
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
{
28
    private $values = ['foo', 'bar'];
29
30
    private $valueType = null;
31
32
    public function let()
33
    {
34
        $this->beConstructedWith($this->values, $this->valueType);
35
    }
36
37
    public function it_is_a_values()
38
    {
39
        $this->shouldBeAnInstanceOf(Values::class);
40
    }
41
42
    public function it_is_a_operand()
43
    {
44
        $this->shouldBeAnInstanceOf(Operand::class);
45
    }
46
47
    public function it_is_transformable(QueryBuilder $qb, ArrayCollection $parameters)
48
    {
49
        $dqlAlias = 'a';
50
51
        $qb->getParameters()->willReturn($parameters);
52
        $parameters->count()->willReturn(10);
53
54
        $qb->setParameter('comparison_10', $this->values, $this->valueType)->shouldBeCalled();
55
56
        $this->transform($qb, $dqlAlias)->shouldReturn(':comparison_10');
57
    }
58
59
    public function it_is_transformable_dbal_type(QueryBuilder $qb, ArrayCollection $parameters)
60
    {
61
        $valueType = Type::DATE;
0 ignored issues
show
Deprecated Code introduced by
The constant Doctrine\DBAL\Types\Type::DATE has been deprecated with message: Use {@see Types::DATE_MUTABLE} instead.

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
62
        $this->beConstructedWith($this->values, $valueType);
63
64
        $qb->getParameters()->willReturn($parameters);
65
        $parameters->count()->willReturn(10);
66
67
        $qb->setParameter('comparison_10', $this->values, $valueType)->shouldBeCalled();
68
69
        $this->transform($qb, 'a')->shouldReturn(':comparison_10');
70
    }
71
72
    public function it_is_transformable_pdo_type(QueryBuilder $qb, ArrayCollection $parameters)
73
    {
74
        $valueType = \PDO::PARAM_INT;
75
        $this->beConstructedWith($this->values, $valueType);
76
77
        $qb->getParameters()->willReturn($parameters);
78
        $parameters->count()->willReturn(10);
79
80
        $qb->setParameter('comparison_10', $this->values, $valueType)->shouldBeCalled();
81
82
        $this->transform($qb, 'a')->shouldReturn(':comparison_10');
83
    }
84
}
85