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.
Completed
Push — master ( 4f73cb...936318 )
by Burhan
02:12
created

CollationInfoTest::providerConstructorWithBadArgs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Graze\Morphism\Parse;
4
5
class CollationInfoTest extends \Graze\Morphism\Test\Parse\TestCase
6
{
7
    public function testConstructor()
8
    {
9
        $collation = new CollationInfo();
10
        $this->assertThat($collation, $this->isInstanceOf(__NAMESPACE__ . '\CollationInfo'));
11
    }
12
13
    /**
14
     * @dataProvider providerConstructorWithArgs
15
     * @param string|null $charset
16
     * @param string|null $collation
17
     * @param string $expectedCharset
18
     * @param string $expectedCollation
19
     */
20
    public function testConstructorWithArgs($charset, $collation, $expectedCharset, $expectedCollation)
21
    {
22
        $collation = new CollationInfo($charset, $collation);
23
        $this->assertSame($expectedCharset, $collation->getCharset());
24
        $this->assertSame($expectedCollation, $collation->getCollation());
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function providerConstructorWithArgs()
31
    {
32
        return [
33
            ['utf8',   null,                'utf8',   'utf8_general_ci'],
34
            ['UTF8',   null,                'utf8',   'utf8_general_ci'],
35
            ['utf8',   'utf8_general_ci',   'utf8',   'utf8_general_ci'],
36
            [null,     'utf8_general_ci',   'utf8',   'utf8_general_ci'],
37
            [null,     'UTF8_GENERAL_CI',   'utf8',   'utf8_general_ci'],
38
39
            ['utf8',   'utf8_unicode_ci',   'utf8',   'utf8_unicode_ci'],
40
            [null,     'utf8_unicode_ci',   'utf8',   'utf8_unicode_ci'],
41
42
            ['latin1', null,                'latin1', 'latin1_swedish_ci'],
43
            ['latin1', 'latin1_swedish_ci', 'latin1', 'latin1_swedish_ci'],
44
            [null,     'latin1_swedish_ci', 'latin1', 'latin1_swedish_ci'],
45
            [null,     'latin1_general_ci', 'latin1', 'latin1_general_ci'],
46
47
            ['binary', null,                'binary', 'binary'],
48
            ['binary', 'binary',            'binary', 'binary'],
49
            [null,     'binary',            'binary', 'binary'],
50
        ];
51
    }
52
53
    /**
54
     * @param string $charset
55
     * @param string $collation
56
     * @dataProvider providerConstructorWithBadArgs
57
     * @expectedException \RuntimeException
58
     */
59
    public function testConstructorWithBadArgs($charset, $collation)
60
    {
61
        $collation = new CollationInfo($charset, $collation);
0 ignored issues
show
Unused Code introduced by
$collation is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
62
    }
63
64
    /**
65
     * @return array
66
     */
67
    public function providerConstructorWithBadArgs()
68
    {
69
        return [
70
            // Invalid character set
71
            ['foo', 'utf8_general_ci'],
72
            // Invalid collation
73
            ['utf8', 'foo'],
74
        ];
75
    }
76
77
    public function testIsSpecified()
78
    {
79
        $this->assertFalse((new CollationInfo)->isSpecified());
80
        $this->assertTrue((new CollationInfo('utf8'))->isSpecified());
81
        $this->assertTrue((new CollationInfo(null, 'utf8_general_ci'))->isSpecified());
82
    }
83
84
    public function testSetBinaryCollation()
85
    {
86
        $collation = new CollationInfo();
87
        $collation->setBinaryCollation();
88
        $collation->setCharset('utf8');
89
        $this->assertSame('utf8_bin', $collation->getCollation());
90
91
        $collation = new CollationInfo();
92
        $collation->setCharset('utf8');
93
        $collation->setBinaryCollation();
94
        $this->assertSame('utf8_bin', $collation->getCollation());
95
    }
96
97
    public function testIsBinaryCharset()
98
    {
99
        $this->assertTrue((new CollationInfo('binary'))->isBinaryCharset());
100
        $this->assertFalse((new CollationInfo('utf8'))->isBinaryCharset());
101
        $this->assertFalse((new CollationInfo('utf8', 'utf8_bin'))->isBinaryCharset());
102
    }
103
104
    /** @expectedException \LogicException */
105
    public function testInvalidIsBinaryCharset()
106
    {
107
        (new CollationInfo())->isBinaryCharset();
108
    }
109
110
    public function testIsDefaultCollation()
111
    {
112
        $this->assertTrue((new CollationInfo('utf8'))->isDefaultCollation());
113
        $this->assertTrue((new CollationInfo('utf8', 'utf8_general_ci'))->isDefaultCollation());
114
        $this->assertTrue((new CollationInfo('latin1'))->isDefaultCollation());
115
        $this->assertTrue((new CollationInfo('binary'))->isDefaultCollation());
116
117
        $this->assertFalse((new CollationInfo('utf8', 'utf8_unicode_ci'))->isDefaultCollation());
118
        $this->assertFalse((new CollationInfo('latin1', 'latin1_general_ci'))->isDefaultCollation());
119
    }
120
121
    /** @expectedException \LogicException */
122
    public function testInvalidSiDefaulfCollation()
123
    {
124
        (new CollationInfo())->isDefaultCollation();
125
    }
126
127
    public function testSetCharset()
128
    {
129
        $collation = new CollationInfo();
130
        $collation->setCharset('utf8');
131
        $this->assertSame('utf8', $collation->getCharset());
132
133
        $collation = new CollationInfo('utf8', 'utf8_bin');
134
        $collation->setCharset('utf8');
135
        $this->assertSame('utf8', $collation->getCharset());
136
    }
137
138
    /** @expectedException \Exception */
139
    public function testSetCharsetFail()
140
    {
141
        (new CollationInfo('latin1'))->setCharset('utf8');
142
    }
143
144
    /** @expectedException \LogicException */
145
    public function testEmptyCharsetFail()
146
    {
147
        (new CollationInfo())->getCharset();
148
    }
149
150
    public function testSetCollation()
151
    {
152
        $collation = new CollationInfo();
153
        $collation->setCollation('utf8_unicode_ci');
154
        $this->assertSame('utf8', $collation->getCharset());
155
        $this->assertSame('utf8_unicode_ci', $collation->getCollation());
156
157
        $collation = new CollationInfo('utf8', 'utf8_unicode_ci');
158
        $collation->setCollation('utf8_general_ci');
159
        $this->assertSame('utf8', $collation->getCharset());
160
        $this->assertSame('utf8_general_ci', $collation->getCollation());
161
    }
162
163
    /** @expectedException \Exception */
164
    public function testSetCollationFail()
165
    {
166
        (new CollationInfo('latin1'))->setCollation('utf8_general_ci');
167
    }
168
169
    public function testGetCollation()
170
    {
171
        $collation = new CollationInfo(null, 'utf8_unicode_ci');
172
        $this->assertSame('utf8_unicode_ci', $collation->getCollation());
173
174
        $collation->setBinaryCollation();
175
        $this->assertSame('utf8_bin', $collation->getCollation());
176
    }
177
178
    /** @expectedException \LogicException */
179
    public function testEmptyCollationFail()
180
    {
181
        (new CollationInfo())->getCollation();
182
    }
183
}
184