Passed
Push — master ( 70a816...07fbff )
by Kevin
09:42 queued 06:43
created

failed_result_contains_non_error_output()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
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\Runner;
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 Zenstruck\ScheduleBundle\Schedule\Task\ProcessTask;
7
use Zenstruck\ScheduleBundle\Schedule\Task\Runner\ProcessTaskRunner;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
final class ProcessTaskRunnerTest extends TestCase
13
{
14
    /**
15
     * @test
16
     */
17
    public function can_create_successful_result()
18
    {
19
        $result = (new ProcessTaskRunner())(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 ProcessTaskRunner())(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 failed_result_contains_non_error_output()
42
    {
43
        $result = (new ProcessTaskRunner())(new ProcessTask(\sprintf('$(which php) %s', __DIR__.'/../../../Fixture/script.sh')));
44
45
        $this->assertTrue($result->isFailure());
46
        $this->assertSame('Exit 1: General error', $result->getDescription());
47
        $this->assertSame("non-error output\nerror output\n", $result->getOutput());
48
    }
49
}
50