Completed
Push — master ( 3260ca...0c0ec5 )
by Christian
02:12
created

ProcessArgumentsTest::processCreation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/*
3
 * @author Tom Klingenberg <https://github.com/ktomk>
4
 */
5
6
namespace N98\Util;
7
8
use Symfony\Component\Process\Process;
9
10
/**
11
 * Class ProcessArgumentsTest
12
 *
13
 * @covers \N98\Util\ProcessArguments
14
 * @package N98\Util
15
 */
16
class ProcessArgumentsTest extends \PHPUnit\Framework\TestCase
17
{
18
    /**
19
     * @test
20
     */
21
    public function creation()
22
    {
23
        $args = new ProcessArguments();
24
        $this->assertInstanceOf(ProcessArguments::class, $args);
25
        $args = ProcessArguments::create();
26
        $this->assertInstanceOf(ProcessArguments::class, $args);
27
    }
28
29
    /**
30
     * @test
31
     */
32
    public function processCreation()
33
    {
34
        $actual = ProcessArguments::create()->createProcess();
35
        $this->assertInstanceOf(Process::class, $actual);
36
    }
37
38
    /**
39
     * @test
40
     */
41
    public function chaining()
42
    {
43
        $actual = ProcessArguments::create()
44
            ->addArg('command')
45
            ->addArgs(['-vvv', '--version-tricks-off', '--', '--' => true])
46
            ->addArg('--')
47
            ->addArgs(['-vvv', '--file' => 'music', '--empty' => true, 'flag' => true])
48
            ->createProcess();
49
        $this->assertInstanceOf(Process::class, $actual);
50
        $commandLine = $actual->getCommandLine();
51
        $this->assertSame(
52
            "'command' '-vvv' '--version-tricks-off' '--' '--' '--' '-vvv' '--file=music' '--empty' '--flag'",
53
            $commandLine
54
        );
55
    }
56
}
57