GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#37)
by Simone
05:59
created

testProvideSubstitutionPatternIfDefinedInConstructor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use Mado\QueryBundle\Objects\Operator;
4
use PHPUnit\Framework\TestCase;
5
6
class OperatorTest extends TestCase
7
{
8
    public function testIsEqualByDefault()
9
    {
10
        $op = Operator::getDefault();
11
        $this->assertEquals('=', $op->getMeta());
12
    }
13
14
    /**
15
     * @expectedException \RuntimeException
16
     * @expectedExceptionMessage Raw operator must contain `meta` parameter
17
     */
18
    public function testCreationIsInvalidWithoutMetaParameter()
19
    {
20
        Operator::fromRawValue([
21
            // invalid raw value
22
        ]);
23
    }
24
25
    public function testCreationIsValidWithMetaParameter()
26
    {
27
        $op = Operator::fromRawValue([
28
            'meta' => '=',
29
        ]);
30
31
        $this->assertEquals(
32
            '=',
33
            $op->getMeta()
34
        );
35
    }
36
37
    /**
38
     * @expectedException \RuntimeException
39
     * @expectedExceptionMessage Oops! Current operator have not substitution pattern.
40
     */
41
    public function testThrowExceptionIfSubstitutionPatternIsRequsted()
42
    {
43
        $op = Operator::fromRawValue([
44
            'meta' => '=',
45
        ]);
46
47
        $op->getSubstitutionPattern();
48
    }
49
50
    public function testProvideSubstitutionPatternIfDefinedInConstructor()
51
    {
52
        $op = Operator::fromRawValue([
53
            'meta' => '=',
54
            'substitution_pattern' => 'foo',
55
        ]);
56
57
        $this->assertEquals(
58
            'foo',
59
            $op->getSubstitutionPattern()
60
        );
61
    }
62
63
    public function testReturnDefaultOperatorWheneverFilteringObjectHasNoOperator()
64
    {
65
        $this->filteringObject = $this
0 ignored issues
show
Bug Best Practice introduced by
The property filteringObject does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
66
            ->getMockBuilder('Mado\QueryBundle\Objects\FilteringObject')
67
            ->disableOriginalConstructor()
68
            ->getMock();
69
        $this->filteringObject->expects($this->once())
70
            ->method('hasOperator')
71
            ->will($this->returnValue(false));
72
73
        $op = Operator::fromFilteringObject($this->filteringObject);
74
75
        $this->assertEquals(
76
            $op,
77
            Operator::getDefault()
78
        );
79
    }
80
81
    public function testDontReturnDefaultOperatorWheneverFilteringObjectHasOperator()
82
    {
83
        $this->filteringObject = $this
0 ignored issues
show
Bug Best Practice introduced by
The property filteringObject does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
84
            ->getMockBuilder('Mado\QueryBundle\Objects\FilteringObject')
85
            ->disableOriginalConstructor()
86
            ->getMock();
87
        $this->filteringObject->expects($this->once())
88
            ->method('hasOperator')
89
            ->will($this->returnValue(true));
90
        $this->filteringObject->expects($this->once())
91
            ->method('getOperator')
92
            ->will($this->returnValue('list'));
93
94
        $op = Operator::fromFilteringObject($this->filteringObject);
95
96
        $this->assertNotEquals($op, Operator::getDefault());
97
    }
98
}
99