Completed
Branch 3.0.0 (d1c058)
by Serhii
02:32
created

bootstrap.php ➔ testUaListIsProperty()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 4
dl 0
loc 7
rs 9.4285
1
<?php
2
/**
3
 * @author Sergey Nehaenko <[email protected]>
4
 * @license GPL
5
 * @copyright Sergey Nehaenko &copy 2016
6
 * @version 1.0
7
 * @project browser-detector
8
 */
9
10
$vendor = realpath(__DIR__ . '/../vendor/');
11
12
define('__SRC__',str_replace('tests','src',__DIR__));
13
if (file_exists($vendor . '/autoload.php')) {
14
    require $vendor . '/autoload.php';
15
} else {
16
    $vendor = realpath(__DIR__ . '/../../../');
17
    if (file_exists($vendor . '/autoload.php')) {
18
        require $vendor . '/autoload.php';
19
    } else {
20
        throw new Exception('Unable to load dependencies');
21
    }
22
}
23
24
use Symfony\Component\ClassLoader\Psr4ClassLoader;
25
use EndorphinStudio\Detector\Detector;
26
27
$loader = new Psr4ClassLoader();
28
$loader->addPrefix('EndorphinStudio\\Detector', __SRC__);
29
$loader->register();
30
31
function testUaList($object,$detectorProperty,$property,$uaList,$expectedValue)
32
{
33
    foreach($uaList as $ua)
34
    {
35
        $obj = Detector::analyse($ua)->$detectorProperty;
36
        $func = 'get'.$property;
37
        $object->assertEquals($expectedValue,$obj->$func());
38
    }
39
}
40
41
function testUaListBooleanTrue($object,$detectorProperty,$property,$uaList)
42
{
43
    foreach($uaList as $ua)
44
    {
45
        $obj = Detector::analyse($ua)->$detectorProperty;
46
        $func = 'is'.$property;
47
        $object->assertTrue($obj->$func(),'Object Property '.$property.' is no equal TRUE');
48
    }
49
}
50
51
function testUaListIsProperty($object,$detectorProperty,$uaList,$expectedValue)
52
{
53
    foreach($uaList as $ua)
54
    {
55
        $object->assertEquals($expectedValue,Detector::analyse($ua)->$detectorProperty);
56
    }
57
}