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

ProcessArgumentsTest::builderCreation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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