OperatingSystemTest::testIsMacOs()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 6
loc 6
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
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 OperatingSystemTest
12
 *
13
 * @package N98\Util
14
 * @covers N98\Util\OperatingSystem
15
 */
16
class OperatingSystemTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * @test
20
     */
21
    public function osDetection()
22
    {
23
        $matrix = array(
24
            OperatingSystem::isLinux(),
25
            OperatingSystem::isWindows(),
26
            OperatingSystem::isMacOs(),
27
            OperatingSystem::isNetware(),
28
        );
29
30
        $this->assertCount(4, $matrix, 'Number of OSes to check for');
31
        $this->assertCount(1, array_filter($matrix), 'One OS must be detected');
32
    }
33
34
    /**
35
     * @requires OS Linux
36
     */
37 View Code Duplication
    public function testIsLinux() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
        $this->assertTrue(OperatingSystem::isLinux());
39
        $this->assertFalse(OperatingSystem::isWindows());
40
        $this->assertFalse(OperatingSystem::isMacOs());
41
        $this->assertFalse(OperatingSystem::isNetware());
42
    }
43
44
    /**
45
     * @requires OS Win
46
     */
47 View Code Duplication
    public function testIsWindows() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
        $this->assertTrue(OperatingSystem::isWindows());
49
        $this->assertFalse(OperatingSystem::isLinux());
50
        $this->assertFalse(OperatingSystem::isMacOs());
51
        $this->assertFalse(OperatingSystem::isNetware());
52
    }
53
54
    /**
55
     * @requires OS Darwin|Mac
56
     */
57 View Code Duplication
    public function testIsMacOs() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
        $this->assertTrue(OperatingSystem::isMacOs());
59
        $this->assertFalse(OperatingSystem::isLinux());
60
        $this->assertFalse(OperatingSystem::isWindows());
61
        $this->assertFalse(OperatingSystem::isNetware());
62
    }
63
64
    /**
65
     * @requires OS netware
66
     */
67 View Code Duplication
    public function testIsNetware() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
        $this->assertTrue(OperatingSystem::isNetware());
69
        $this->assertFalse(OperatingSystem::isLinux());
70
        $this->assertFalse(OperatingSystem::isWindows());
71
        $this->assertFalse(OperatingSystem::isMacOs());
72
    }
73
74
    /**
75
     * @test
76
     */
77
    public function getCwd()
78
    {
79
        $expected = getcwd();
80
        $this->assertEquals($expected, OperatingSystem::getCwd());
81
    }
82
}
83