1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenstruck\ScheduleBundle\Tests\Schedule\Task; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
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 has_default_description() |
18
|
|
|
{ |
19
|
|
|
$this->assertSame('$(which php) -v', (new ProcessTask('$(which php) -v'))->getDescription()); |
20
|
|
|
$this->assertSame('$(which php) -v', (new ProcessTask(Process::fromShellCommandline('$(which php) -v')))->getDescription()); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @test |
25
|
|
|
*/ |
26
|
|
|
public function can_create_successful_result() |
27
|
|
|
{ |
28
|
|
|
$result = (new ProcessTask('$(which php) -v'))(); |
29
|
|
|
|
30
|
|
|
$this->assertTrue($result->isSuccessful()); |
31
|
|
|
$this->assertStringContainsString('PHP', $result->getOutput()); |
32
|
|
|
$this->assertStringContainsString(PHP_VERSION, $result->getOutput()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @test |
37
|
|
|
*/ |
38
|
|
|
public function can_create_failed_result() |
39
|
|
|
{ |
40
|
|
|
$result = (new ProcessTask('sdfsdfsdf'))(); |
41
|
|
|
|
42
|
|
|
$this->assertTrue($result->isFailure()); |
43
|
|
|
$this->assertSame('Exit 127: Command not found', $result->getDescription()); |
44
|
|
|
$this->assertSame("sh: 1: sdfsdfsdf: not found\n", $result->getOutput()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @test |
49
|
|
|
*/ |
50
|
|
|
public function can_add_a_process_instance() |
51
|
|
|
{ |
52
|
|
|
$result = (new ProcessTask(Process::fromShellCommandline('$(which php) -v')))(); |
53
|
|
|
|
54
|
|
|
$this->assertTrue($result->isSuccessful()); |
55
|
|
|
$this->assertStringContainsString('PHP', $result->getOutput()); |
56
|
|
|
$this->assertStringContainsString(PHP_VERSION, $result->getOutput()); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @test |
61
|
|
|
*/ |
62
|
|
|
public function task_has_context() |
63
|
|
|
{ |
64
|
|
|
$task = new ProcessTask('/foo/bar'); |
65
|
|
|
$this->assertSame(['Command Line' => '/foo/bar', 'Command Timeout' => 60.0], $task->getContext()); |
66
|
|
|
|
67
|
|
|
$task = new ProcessTask(Process::fromShellCommandline('/foo/bar')->setTimeout(30)); |
68
|
|
|
$this->assertSame(['Command Line' => '/foo/bar', 'Command Timeout' => 30.0], $task->getContext()); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths