Completed
Push — develop ( c8bccb...27dcf1 )
by Tom
04:44
created

ProcessArgumentsTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 4
dl 0
loc 42
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A creation() 0 7 1
A builderCreation() 0 5 1
A chaining() 0 16 1
1
<?php
2
/*
3
 * @author Tom Klingenberg <https://github.com/ktomk>
4
 */
5
6
namespace N98\Util;
7
8
use PHPUnit_Framework_TestCase;
9
use Symfony\Component\Process\ProcessBuilder;
10
11
/**
12
 * Class ProcessArgumentsTest
13
 *
14
 * @covers N98\Util\ProcessArguments
15
 * @package N98\Util
16
 */
17
class ProcessArgumentsTest extends PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @test
21
     */
22
    public function creation()
23
    {
24
        $args = new ProcessArguments();
25
        $this->assertInstanceOf(ProcessArguments::class, $args);
26
        $args = ProcessArguments::create();
27
        $this->assertInstanceOf(ProcessArguments::class, $args);
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function builderCreation()
34
    {
35
        $actual = ProcessArguments::create()->createBuilder();
36
        $this->assertInstanceOf(ProcessBuilder::class, $actual);
37
    }
38
39
    /**
40
     * @test
41
     */
42
    public function chaining()
43
    {
44
        $actual = ProcessArguments::create()
45
            ->addArg('command')
46
            ->addArgs(array('-vvv', '--version-tricks-off', '--', '--' => true))
47
            ->addArg('--')
48
            ->addArgs(array('-vvv', '--file' => 'music', '--empty' => true, 'flag' => true))
49
            ->createBuilder()
50
            ;
51
        $this->assertInstanceOf(ProcessBuilder::class, $actual);
52
        $commandLine = $actual->getProcess()->getCommandLine();
53
        $this->assertSame(
54
            "'command' '-vvv' '--version-tricks-off' '--' '--' '--' '-vvv' '--file=music' '--empty' '--flag'",
55
            $commandLine
56
        );
57
    }
58
}
59