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.

testSetInputFilterThrowsExceptionWhenInvoked()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace RbCommentTest\Model;
3
4
use RbComment\Model\Comment;
5
use Zend\InputFilter\InputFilter;
6
use PHPUnit_Framework_TestCase;
7
8
class CommentTest extends PHPUnit_Framework_TestCase
9
{
10
    protected $testComment;
11
    protected $testArray;
12
13
    public function setUp()
14
    {
15
        $this->testComment = new Comment();
16
17
        $this->testArray = [
18
            'id'           => 1,
19
            'thread'       => 12345,
20
            'uri'          => 'test-uri',
21
            'author'       => 'Robert Boloc',
22
            'contact'      => '[email protected]',
23
            'content'      => 'This is a test comment',
24
            'visible'      => 1,
25
            'spam'         => 0,
26
            'published_on' => 12345678,
27
        ];
28
    }
29
30
    /**
31
     * @group model
32
     */
33
    public function testCommentInitialState()
34
    {
35
        $this->assertNull($this->testComment->id);
36
        $this->assertNull($this->testComment->thread);
37
        $this->assertNull($this->testComment->uri);
38
        $this->assertNull($this->testComment->author);
39
        $this->assertNull($this->testComment->contact);
40
        $this->assertNull($this->testComment->content);
41
        $this->assertNull($this->testComment->visible);
42
        $this->assertNull($this->testComment->spam);
43
        $this->assertNull($this->testComment->published_on);
44
    }
45
46
    /**
47
     * @group model
48
     */
49
    public function testExchangeArrayExchangesTheValues()
50
    {
51
        $this->testComment->exchangeArray($this->testArray);
52
53
        $this->assertEquals($this->testArray['id'], $this->testComment->id);
54
        $this->assertEquals($this->testArray['thread'], $this->testComment->thread);
55
        $this->assertEquals($this->testArray['uri'], $this->testComment->uri);
56
        $this->assertEquals($this->testArray['author'], $this->testComment->author);
57
        $this->assertEquals($this->testArray['contact'], $this->testComment->contact);
58
        $this->assertEquals($this->testArray['content'], $this->testComment->content);
59
        $this->assertEquals($this->testArray['visible'], $this->testComment->visible);
60
        $this->assertEquals($this->testArray['spam'], $this->testComment->spam);
61
        $this->assertEquals($this->testArray['published_on'], $this->testComment->published_on);
62
    }
63
64
    /**
65
     * @group model
66
     */
67
    public function testToArrayReturnsAllTheValues()
68
    {
69
        $this->testComment->exchangeArray($this->testArray);
70
71
        $resultArray = $this->testComment->toArray();
72
73
        $this->assertEquals($this->testArray['id'], $resultArray['id']);
74
        $this->assertEquals($this->testArray['thread'], $resultArray['thread']);
75
        $this->assertEquals($this->testArray['uri'], $resultArray['uri']);
76
        $this->assertEquals($this->testArray['author'], $resultArray['author']);
77
        $this->assertEquals($this->testArray['contact'], $resultArray['contact']);
78
        $this->assertEquals($this->testArray['content'], $resultArray['content']);
79
        $this->assertEquals($this->testArray['visible'], $resultArray['visible']);
80
        $this->assertEquals($this->testArray['spam'], $resultArray['spam']);
81
        $this->assertEquals($this->testArray['published_on'], $resultArray['published_on']);
82
    }
83
84
    /**
85
     * @group model
86
     * @expectedException Exception
87
     * @expectedExceptionMessage Not used
88
     */
89
    public function testSetInputFilterThrowsExceptionWhenInvoked()
90
    {
91
        $this->testComment->setInputFilter(new InputFilter());
92
    }
93
94
    /**
95
     * @group model
96
     * @dataProvider inputFilterDataProvider
97
     */
98
    public function testGetInputFilterValidation($data, $validity)
99
    {
100
        $inputFilter = $this->testComment->getInputFilter();
101
        $inputFilter->setData($data);
102
103
        $this->assertEquals($inputFilter->isValid(), $validity);
104
    }
105
106
    /**
107
     * @return array
108
     */
109
    public static function inputFilterDataProvider()
110
    {
111
        return [
112
            // False because no data is sent
113
            [
114
                [],
115
                false,
116
            ],
117
            // True because everything is ok
118
            [
119
                [
120
                    'id'      => 1,
121
                    'thread'  => md5('test'),
122
                    'author'  => 'Robert Boloc',
123
                    'contact' => '[email protected]',
124
                    'content' => 'bla bla bla',
125
                ],
126
                true,
127
            ],
128
        ];
129
    }
130
}
131