Test Failed
Pull Request — master (#17)
by Denis
10:14
created

BetweenTest::testGetExpr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 0
dl 0
loc 26
rs 9.6666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Tests\Unit\Artprima\QueryFilterBundle\Query\Condition;
4
5
use Artprima\QueryFilterBundle\Query\Condition\Between;
6
use Artprima\QueryFilterBundle\Query\Filter;
7
use Doctrine\ORM\Query\Expr;
8
use Doctrine\ORM\QueryBuilder;
9
use PHPUnit\Framework\TestCase;
10
11
/**
12
 * Class BetweenTest
13
 *
14
 * @author Denis Voytyuk <[email protected]>
15
 */
16
class BetweenTest extends TestCase
17
{
18
    public function testGetExpr()
19
    {
20
        $qb = $this->getMockBuilder(QueryBuilder::class)
21
            ->disableOriginalConstructor()
22
            ->getMock();
23
24
        $qb
25
            ->expects(self::once())
26
            ->method('expr')
27
            ->willReturn(new Expr());
28
29
        $qb
30
            ->expects($this->exactly(2))
31
            ->method('setParameter')
32
            ->withConsecutive(['x0', 1], ['y0', 10])
33
            ->willReturn($qb);
34
35
        $condition = new Between();
36
37
        $expr = $condition->getExpr($qb, 0, (new Filter())
38
            ->setField('t.dummy')
39
            ->setX(1)
40
            ->setY(10)
41
        );
42
43
        self::assertSame('t.dummy BETWEEN :x0 AND :y0', $expr);
44
    }
45
}