Completed
Pull Request — master (#912)
by
unknown
07:49
created

WindowsSystemTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isProgramInstalled() 0 8 1
A provideExecutableNames() 0 13 1
A isExecutableName() 0 4 1
1
<?php
2
/**
3
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
8
namespace N98\Util;
9
10
/**
11
 * Class WindowsSystemTest
12
 *
13
 * @package N98\Util
14
 * @requires OS win
15
 */
16
class WindowsSystemTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * @test
20
     */
21
    public function isProgramInstalled()
22
    {
23
        $this->assertTrue(WindowsSystem::isProgramInstalled("notepad"));
24
25
        $this->assertFalse(WindowsSystem::isProgramInstalled("notepad-that-never-made-it-into-windows-kernel"));
26
27
        $this->assertFalse(WindowsSystem::isProgramInstalled("invalid\\command*name|thisis"));
28
    }
29
30
    /**
31
     * @see isExecutableName
32
     * @return array
33
     */
34
    public function provideExecutableNames()
35
    {
36
        return array(
37
            array("notepad", false),
38
            array("notepad.com", true),
39
            array("notepad.exe", true),
40
            array("notepad.exe.exe", true),
41
            array("notepad.eXe", true),
42
            array("notepad.EXE", true),
43
            array("notepad.bat", true),
44
            array("notepad.txt", false),
45
        );
46
    }
47
48
    /**
49
     * @test
50
     *
51
     * @param string $name
52
     * @param bool $expected
53
     * @dataProvider provideExecutableNames
54
     */
55
    public function isExecutableName($name, $expected)
56
    {
57
        $this->assertSame($expected, WindowsSystem::isExecutableName($name), $name);
58
    }
59
}
60