|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Zenstruck\ScheduleBundle\Tests\Schedule\Task; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
|
|
6
|
|
|
use Zenstruck\ScheduleBundle\Schedule\Task\CompoundTask; |
|
7
|
|
|
use Zenstruck\ScheduleBundle\Tests\Fixture\MockTask; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @author Kevin Bond <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
final class CompoundTaskTest extends TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @test |
|
16
|
|
|
*/ |
|
17
|
|
|
public function cannot_nest_compound_tasks() |
|
18
|
|
|
{ |
|
19
|
|
|
$task = new CompoundTask(); |
|
20
|
|
|
|
|
21
|
|
|
$this->expectException(\LogicException::class); |
|
22
|
|
|
$this->expectExceptionMessage('Cannot nest compound tasks.'); |
|
23
|
|
|
|
|
24
|
|
|
$task->add(new CompoundTask()); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @test |
|
29
|
|
|
*/ |
|
30
|
|
|
public function config_is_passed_to_sub_tasks(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$task = new CompoundTask(); |
|
33
|
|
|
$task->add(new MockTask('subtask1')); |
|
34
|
|
|
$task->add(new MockTask('subtask2')); |
|
35
|
|
|
$task->config()->set('foo', 'bar'); |
|
36
|
|
|
$task->config()->set('bar', 'foo'); |
|
37
|
|
|
|
|
38
|
|
|
[$subtask1, $subtask2] = \iterator_to_array($task); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertSame('bar', $subtask1->config()->get('foo')); |
|
41
|
|
|
$this->assertSame('foo', $subtask1->config()->get('bar')); |
|
42
|
|
|
$this->assertSame('bar', $subtask2->config()->get('foo')); |
|
43
|
|
|
$this->assertSame('foo', $subtask2->config()->get('bar')); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @test |
|
48
|
|
|
*/ |
|
49
|
|
|
public function config_on_sub_tasks_takes_precedence_over_compound_task(): void |
|
50
|
|
|
{ |
|
51
|
|
|
$subTask = new MockTask('subtask'); |
|
52
|
|
|
$subTask->config()->set('key2', 'subtask value2'); |
|
53
|
|
|
$task = new CompoundTask(); |
|
54
|
|
|
$task->config()->set('key1', 'compound value1'); |
|
55
|
|
|
$task->config()->set('key2', 'compound value2'); |
|
56
|
|
|
$task->add($subTask); |
|
57
|
|
|
|
|
58
|
|
|
[$subTask] = \iterator_to_array($task); |
|
59
|
|
|
|
|
60
|
|
|
$this->assertSame('compound value1', $subTask->config()->get('key1')); |
|
61
|
|
|
$this->assertSame('subtask value2', $subTask->config()->get('key2')); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
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