UtilsTest::testWhoAmI()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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