UtilsTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsCli() 0 4 1
A testWhoAmI() 0 7 1
A testNumbersToRangeText() 0 4 1
A getNumbersToRangeTextData() 0 10 1
1
<?php
2
3
namespace Mathielen\ImportEngineBundle\Tests;
4
5
use Mathielen\ImportEngineBundle\Utils;
6
7
class UtilsTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testIsCli()
10
    {
11
        $this->assertTrue(Utils::isCli());
12
    }
13
14
    public function testWhoAmI()
15
    {
16
        $processUser = posix_getpwuid(posix_geteuid());
17
        $actualUser = $processUser['name'];
18
19
        $this->assertEquals($actualUser, Utils::whoAmI());
20
    }
21
22
    /**
23
     * @dataProvider getNumbersToRangeTextData
24
     */
25
    public function testNumbersToRangeText(array $range, $expected)
26
    {
27
        $this->assertEquals($expected, Utils::numbersToRangeText($range));
28
    }
29
30
    public function getNumbersToRangeTextData()
31
    {
32
        return [
33
            [[], []],
34
            [[1], ['1']],
35
            [[1, 2, 3], ['1-3']],
36
            [[1, 2, 4, 5], ['1-2', '4-5']],
37
            [[1, 3, 5, 7], ['1', '3', '5', '7']],
38
        ];
39
    }
40
}
41