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.

TimelineBuilderTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 7
c 6
b 0
f 0
lcom 1
cbo 4
dl 0
loc 90
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testUserTimeline() 0 7 1
A testWidgetRenderingWithJs() 0 20 1
A testWidgetRenderingWithoutJs() 0 20 1
A testOneTimeJsReturnsNeededCode() 0 11 1
A testNonBoolThrowException() 0 7 1
A testUnsetValuesAreNotRendered() 0 7 1
1
<?php
2
/*
3
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
5
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
6
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
7
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
8
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
 */
10
11
namespace TwitterWidgetsTest\Timeline;
12
13
use ReflectionClass;
14
use TwitterWidgets\Options\WidgetOptions;
15
use TwitterWidgets\Timeline\TimelineBuilder;
16
use TwitterWidgetsTest\Assets\OptionsProvider;
17
18
class TimelineBuilderTest extends OptionsProvider
19
{
20
    protected $widgetOptions;
21
22
    protected function setUp()
23
    {
24
        $this->widgetOptions = new WidgetOptions($this->arrayProvider()[0][0]);
25
    }
26
27
    public function testUserTimeline()
28
    {
29
        $widgetOptions   = $this->createMock(WidgetOptions::class);
30
        $timelineBuilder = new TimelineBuilder($widgetOptions);
31
32
        $this->assertInstanceOf(TimelineBuilder::class, $timelineBuilder);
33
    }
34
35
    public function testWidgetRenderingWithJs()
36
    {
37
        $timelineBuilder = $this
38
            ->getMockBuilder(TimelineBuilder::class)
39
            ->disableOriginalConstructor()
40
            ->setMethods(['filterAttr', 'getSingleWidgetJs'])
41
            ->getMock();
42
43
        $timelineBuilder
44
            ->expects($this->once())
45
            ->method('filterAttr')
46
            ->willReturn([]);
47
48
        $timelineBuilder
49
            ->expects($this->once())
50
            ->method('getSingleWidgetJs')
51
            ->willReturn('achievement unlocked!');
52
53
        $this->assertGreaterThan(0, strpos($timelineBuilder->renderWidget(), 'achievement unlocked!'));
54
    }
55
56
    public function testWidgetRenderingWithoutJs()
57
    {
58
        $timelineBuilder = $this
59
            ->getMockBuilder(TimelineBuilder::class)
60
            ->disableOriginalConstructor()
61
            ->setMethods(['filterAttr', 'getSingleWidgetJs'])
62
            ->getMock();
63
64
        $timelineBuilder
65
            ->expects($this->once())
66
            ->method('filterAttr')
67
            ->willReturn([]);
68
69
        $timelineBuilder
70
            ->expects($this->never())
71
            ->method('getSingleWidgetJs')
72
            ->willReturn('achievement unlocked!');
73
74
        $this->assertEquals(0, strpos($timelineBuilder->renderWidget(false), 'achievement unlocked!'));
75
    }
76
77
    public function testUnsetValuesAreNotRendered()
78
    {
79
        $this->widgetOptions->setClass(null);
80
        $timelineBuilder = new TimelineBuilder($this->widgetOptions);
81
82
        $this->assertEquals(0, strpos($timelineBuilder->renderWidget(false), 'class="customClass"'));
83
    }
84
85
    /**
86
     * @expectedException \InvalidArgumentException
87
     */
88
    public function testNonBoolThrowException()
89
    {
90
        $widgetOptions   = $this->createMock(WidgetOptions::class);
91
        $timelineBuilder = new TimelineBuilder($widgetOptions);
92
93
        $timelineBuilder->renderWidget('helloyesthisisdog');
0 ignored issues
show
Documentation introduced by
'helloyesthisisdog' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
94
    }
95
96
    public function testOneTimeJsReturnsNeededCode()
97
    {
98
        $widgetOptions   = $this->createMock(WidgetOptions::class);
99
        $timelineBuilder = new TimelineBuilder($widgetOptions);
100
101
        $reflected = new ReflectionClass(TimelineBuilder::class);
102
        $method    = $reflected->getMethod('getSingleWidgetJs');
103
        $method->setAccessible(true);
104
105
        $this->assertGreaterThan(0, strpos($method->invokeArgs($timelineBuilder, []), 'widgets.js'));
106
    }
107
}
108