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.

DeviceDetectExtensionTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 49
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDetector() 0 8 1
A getFunctionByName() 0 8 3
A testIsTablet() 0 14 1
A extensionFunctions() 0 9 1
1
<?php
2
3
namespace CrossKnowledge\DeviceDetectBundle\Tests\Services;
4
5
use CrossKnowledge\DeviceDetectBundle\DependencyInjection\CrossKnowledgeDeviceDetectExtension;
6
use CrossKnowledge\DeviceDetectBundle\Services\DeviceDetect;
7
use CrossKnowledge\DeviceDetectBundle\Twig\DeviceDetectExtension;
8
9
class DeviceDetectExtensionTest extends \PHPUnit_Framework_TestCase
10
{
11
12
    public function getDetector()
13
    {
14
        $detectorMock = $this->getMockBuilder(DeviceDetect::class)
15
                             ->disableOriginalConstructor()
16
                             ->getMock();
17
18
        return $detectorMock;
19
    }
20
21
    protected function getFunctionByName(\Twig_Extension $extension, $name)
22
    {
23
        foreach ($extension->getFunctions() as $function) {
24
            if ($function->getName()==$name) {
25
                return $function;
26
            }
27
        }
28
    }
29
30
    /**
31
     * @dataProvider extensionFunctions
32
     */
33
    public function testIsTablet($function, $expected, $detectorMethod)
34
    {
35
        $mock = $this->getDetector();
36
37
        $ext = new DeviceDetectExtension($mock);
38
39
        $mock->expects($this->once())->method($detectorMethod)
40
             ->will($this->returnValue($expected));
41
42
        $function = $this->getFunctionByName($ext, $function);
43
        $this->assertNotNull($function);
44
45
        $this->assertEquals(call_user_func($function->getCallable()), $expected);
46
    }
47
48
    public function extensionFunctions()
49
    {
50
        return [
51
            ['is_tablet', true, 'isTablet'],
52
            ['is_tablet', false, 'isTablet'],
53
            ['is_mobile', false, 'isMobile'],
54
            ['is_desktop', false, 'isDesktop'],
55
        ];
56
    }
57
}