Completed
Push — 2.0 ( d7d09e...57ce97 )
by Peter
06:52 queued 12s
created

AvgSpec::it_is_a_operand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Operand\PlatformFunction;
16
17
use Doctrine\ORM\QueryBuilder;
18
use Happyr\DoctrineSpecification\Exception\OperandNotExecuteException;
19
use Happyr\DoctrineSpecification\Operand\Operand;
20
use Happyr\DoctrineSpecification\Operand\PlatformFunction\Avg;
21
use PhpSpec\ObjectBehavior;
22
23
/**
24
 * @mixin Avg
25
 */
26 View Code Duplication
final class AvgSpec 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 $field = 'foo';
29
30
    public function let(): void
31
    {
32
        $this->beConstructedWith($this->field);
33
    }
34
35
    public function it_is_a_count_distinct(): void
36
    {
37
        $this->shouldBeAnInstanceOf(Avg::class);
38
    }
39
40
    public function it_is_a_operand(): void
41
    {
42
        $this->shouldBeAnInstanceOf(Operand::class);
43
    }
44
45
    public function it_is_transformable(QueryBuilder $qb): void
46
    {
47
        $this->transform($qb, 'a')->shouldReturn('AVG(a.foo)');
48
    }
49
50
    public function it_is_transformable_distinct(QueryBuilder $qb): void
51
    {
52
        $this->beConstructedWith($this->field, true);
53
54
        $this->transform($qb, 'a')->shouldReturn('AVG(DISTINCT a.foo)');
55
    }
56
57
    public function it_is_executable(): void
58
    {
59
        $candidate = null; // not used
60
61
        $this->shouldThrow(OperandNotExecuteException::class)->duringExecute($candidate);
62
    }
63
}
64