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.

TwViewHelperTest::testTwViewHelper()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
rs 8.8571
cc 1
eloc 22
nc 1
nop 0
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 ZfTwitterWidgetTests\View;
12
13
use PHPUnit\Framework\TestCase;
14
use TwitterWidgets\Options\WidgetOptions;
15
use TwitterWidgets\Timeline\TimelineBuilder;
16
use ZfTwitterWidget\View\TwViewHelper;
17
18
class TwViewHelperTest extends TestCase
19
{
20
    public function testTwViewHelper()
21
    {
22
        $widgetOption = $this
23
            ->getMockBuilder(WidgetOptions::class)
24
            ->disableOriginalConstructor()
25
            ->getMock();
26
27
        $timelineBuilder = $this
28
            ->getMockBuilder(TimelineBuilder::class)
29
            ->disableOriginalConstructor()
30
            ->setMethods(['filterAttr', 'getSingleWidgetJs'])
31
            ->getMock();
32
33
        $timelineBuilder
34
            ->expects($this->once())
35
            ->method('filterAttr')
36
            ->willReturn([]);
37
38
        $timelineBuilder
39
            ->expects($this->once())
40
            ->method('getSingleWidgetJs')
41
            ->willReturn('achievement unlocked!');
42
43
        $viewHelper = new TwViewHelper(
44
            $widgetOption,
45
            $timelineBuilder
46
        );
47
48
        $this->assertGreaterThan(0, strpos($viewHelper([]), 'achievement unlocked!'));
49
    }
50
51
    /**
52
     * @expectedException \InvalidArgumentException
53
     */
54
    public function testWrongTypeThrowsException()
55
    {
56
        $widgetOption = $this
57
            ->getMockBuilder(WidgetOptions::class)
58
            ->disableOriginalConstructor()
59
            ->getMock();
60
61
        $timelineBuilder = $this
62
            ->getMockBuilder(TimelineBuilder::class)
63
            ->disableOriginalConstructor()
64
            ->getMock();
65
66
        $viewHelper = new TwViewHelper($widgetOption, $timelineBuilder);
67
        $options    = new \stdClass();
68
69
        $viewHelper->__invoke($options);
0 ignored issues
show
Documentation introduced by
$options is of type object<stdClass>, but the function expects a array|object<TwitterWidg...WidgetOptionsInterface>.

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...
70
    }
71
}
72