geBinding_WithOneDimensionFilter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Hgraca\MicroDbal\Test\Crud\QueryBuilder\Sql;
4
5
use Hgraca\MicroDbal\Crud\QueryBuilder\Sql\WhereToken;
6
use PHPUnit_Framework_TestCase;
7
8
final class WhereTokenUnitTest extends PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * @test
12
     *
13
     * @small
14
     */
15
    public function toString_GeneratesCorrectSqlWithAnd()
16
    {
17
        $column = 'dummy_column';
18
        $value = 'something';
19
        $bindingCounter = 5;
20
21
        $whereToken = new WhereToken($column, $value, $bindingCounter);
22
23
        self::assertEquals(
24
            "`$column`" . WhereToken::COMPARISON_EQUAL . WhereToken::BINDING_PREFIX . $bindingCounter,
25
            $whereToken->toString()
26
        );
27
    }
28
29
    /**
30
     * @test
31
     *
32
     * @small
33
     */
34
    public function toString_GeneratesCorrectSqlWithOr()
35
    {
36
        $column = 'dummy_column';
37
        $value = 'something';
38
        $bindingCounter = 5;
39
40
        $whereToken = new WhereToken($column, $value, $bindingCounter);
41
42
        self::assertEquals(
43
            "`$column`" . WhereToken::COMPARISON_EQUAL . WhereToken::BINDING_PREFIX . $bindingCounter,
44
            $whereToken->toString()
45
        );
46
    }
47
48
    /**
49
     * @test
50
     *
51
     * @small
52
     */
53 View Code Duplication
    public function toString_GeneratesCorrectSqlWithIs()
0 ignored issues
show
Duplication introduced by
This method 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...
54
    {
55
        $column = 'dummy_column';
56
        $value = null;
57
        $bindingCounter = 5;
58
59
        $whereToken = new WhereToken($column, $value, $bindingCounter);
60
61
        self::assertEquals(
62
            "`$column`" . WhereToken::COMPARISON_IS . WhereToken::BINDING_PREFIX . $bindingCounter,
63
            $whereToken->toString()
64
        );
65
    }
66
67
    /**
68
     * @test
69
     *
70
     * @small
71
     */
72 View Code Duplication
    public function toString_GeneratesCorrectSqlWithOtherComparison()
0 ignored issues
show
Duplication introduced by
This method 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...
73
    {
74
        $column = 'dummy_column';
75
        $value = 4;
76
        $bindingCounter = 5;
77
78
        $whereToken = new WhereToken($column, $value, $bindingCounter, WhereToken::COMPARISON_HIGHER_OR_EQUAL);
79
80
        self::assertEquals(
81
            "`$column`" . WhereToken::COMPARISON_HIGHER_OR_EQUAL . WhereToken::BINDING_PREFIX . $bindingCounter,
82
            $whereToken->toString()
83
        );
84
    }
85
86
    /**
87
     * @test
88
     *
89
     * @small
90
     */
91
    public function geBinding_WithOneDimensionFilter()
92
    {
93
        $column = 'dummy_column';
94
        $value = 4;
95
        $bindingCounter = 5;
96
97
        $whereToken = new WhereToken($column, $value, $bindingCounter, WhereToken::COMPARISON_HIGHER_OR_EQUAL);
98
99
        self::assertEquals(
100
            [':w5' => 4],
101
            $whereToken->getBinding()
102
        );
103
    }
104
}
105