Code Duplication    Length = 38-38 lines in 5 locations

tests/Operand/PlatformFunction/AvgSpec.php 1 location

@@ 26-63 (lines=38) @@
23
/**
24
 * @mixin Avg
25
 */
26
final class AvgSpec extends ObjectBehavior
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

tests/Operand/PlatformFunction/CountSpec.php 1 location

@@ 26-63 (lines=38) @@
23
/**
24
 * @mixin Count
25
 */
26
final class CountSpec extends ObjectBehavior
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(Count::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('COUNT(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('COUNT(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

tests/Operand/PlatformFunction/MaxSpec.php 1 location

@@ 26-63 (lines=38) @@
23
/**
24
 * @mixin Max
25
 */
26
final class MaxSpec extends ObjectBehavior
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(Max::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('MAX(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('MAX(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

tests/Operand/PlatformFunction/MinSpec.php 1 location

@@ 26-63 (lines=38) @@
23
/**
24
 * @mixin Min
25
 */
26
final class MinSpec extends ObjectBehavior
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(Min::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('MIN(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('MIN(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

tests/Operand/PlatformFunction/SumSpec.php 1 location

@@ 26-63 (lines=38) @@
23
/**
24
 * @mixin Sum
25
 */
26
final class SumSpec extends ObjectBehavior
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(Sum::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('SUM(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('SUM(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