Passed
Push — master ( 18c542...46352d )
by Kevin
02:34
created

ProcessTaskTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A can_create_failed_result() 0 7 1
A can_create_successful_result() 0 7 1
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 Zenstruck\ScheduleBundle\Schedule\Task\ProcessTask;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
final class ProcessTaskTest extends TestCase
12
{
13
    /**
14
     * @test
15
     */
16
    public function can_create_successful_result()
17
    {
18
        $result = (new ProcessTask('$(which php) -v'))->timeout(1)->cwd(__DIR__)();
19
20
        $this->assertTrue($result->isSuccessful());
21
        $this->assertStringContainsString('PHP', $result->getOutput());
22
        $this->assertStringContainsString(PHP_VERSION, $result->getOutput());
23
    }
24
25
    /**
26
     * @test
27
     */
28
    public function can_create_failed_result()
29
    {
30
        $result = (new ProcessTask('sdfsdfsdf'))();
31
32
        $this->assertTrue($result->isFailure());
33
        $this->assertSame('Exit 127: Command not found', $result->getDescription());
34
        $this->assertSame("sh: 1: sdfsdfsdf: not found\n", $result->getOutput());
35
    }
36
}
37