Passed
Pull Request — master (#8)
by Kevin
17:55
created

ProcessTaskRunnerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A can_create_successful_result() 0 7 1
A can_create_failed_result() 0 7 1
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