Passed
Push — master ( 5d8457...25e7ae )
by Kevin
01:58
created

ProcessTaskTest::can_add_a_process_instance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\Tests\Schedule\Task;
4
5
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Symfony\Component\Process\Process;
7
use Zenstruck\ScheduleBundle\Schedule\Task\ProcessTask;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
final class ProcessTaskTest extends TestCase
13
{
14
    /**
15
     * @test
16
     */
17
    public function can_create_successful_result()
18
    {
19
        $result = (new ProcessTask('$(which php) -v'))();
20
21
        $this->assertTrue($result->isSuccessful());
22
        $this->assertStringContainsString('PHP', $result->getOutput());
23
        $this->assertStringContainsString(PHP_VERSION, $result->getOutput());
24
    }
25
26
    /**
27
     * @test
28
     */
29
    public function can_create_failed_result()
30
    {
31
        $result = (new ProcessTask('sdfsdfsdf'))();
32
33
        $this->assertTrue($result->isFailure());
34
        $this->assertSame('Exit 127: Command not found', $result->getDescription());
35
        $this->assertSame("sh: 1: sdfsdfsdf: not found\n", $result->getOutput());
36
    }
37
38
    /**
39
     * @test
40
     */
41
    public function can_add_a_process_instance()
42
    {
43
        $result = (new ProcessTask(Process::fromShellCommandline('$(which php) -v')))();
44
45
        $this->assertTrue($result->isSuccessful());
46
        $this->assertStringContainsString('PHP', $result->getOutput());
47
        $this->assertStringContainsString(PHP_VERSION, $result->getOutput());
48
    }
49
}
50