1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenstruck\ScheduleBundle\Tests\Functional; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
6
|
|
|
use Zenstruck\ScheduleBundle\Schedule; |
7
|
|
|
use Zenstruck\ScheduleBundle\Schedule\ScheduleBuilder; |
8
|
|
|
use Zenstruck\ScheduleBundle\Schedule\Task; |
9
|
|
|
use Zenstruck\ScheduleBundle\Tests\Fixture\MockScheduleBuilder; |
10
|
|
|
use Zenstruck\ScheduleBundle\Tests\Fixture\MockTask; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @author Kevin Bond <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
final class SelfHandlingExtensionTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @test |
19
|
|
|
*/ |
20
|
|
|
public function success_hooks_are_called() |
21
|
|
|
{ |
22
|
|
|
$builder = $this->createBuilder(MockTask::success()); |
23
|
|
|
|
24
|
|
|
(new MockScheduleBuilder()) |
25
|
|
|
->addBuilder($builder) |
26
|
|
|
->run() |
27
|
|
|
; |
28
|
|
|
|
29
|
|
|
$this->assertSame([ |
30
|
|
|
'scheduleFilter', |
31
|
|
|
'scheduleBefore', |
32
|
|
|
'taskFilter', |
33
|
|
|
'taskBefore', |
34
|
|
|
'taskAfter', |
35
|
|
|
'taskSuccess', |
36
|
|
|
'scheduleAfter', |
37
|
|
|
'scheduleSuccess', |
38
|
|
|
], $builder->calls); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @test |
43
|
|
|
*/ |
44
|
|
|
public function failure_hooks_are_called() |
45
|
|
|
{ |
46
|
|
|
$builder = $this->createBuilder(MockTask::exception(new \Exception())); |
47
|
|
|
|
48
|
|
|
(new MockScheduleBuilder()) |
49
|
|
|
->addBuilder($builder) |
50
|
|
|
->run() |
51
|
|
|
; |
52
|
|
|
|
53
|
|
|
$this->assertSame([ |
54
|
|
|
'scheduleFilter', |
55
|
|
|
'scheduleBefore', |
56
|
|
|
'taskFilter', |
57
|
|
|
'taskBefore', |
58
|
|
|
'taskAfter', |
59
|
|
|
'taskFailure', |
60
|
|
|
'scheduleAfter', |
61
|
|
|
'scheduleFailure', |
62
|
|
|
], $builder->calls); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
private function createBuilder(callable $callback): ScheduleBuilder |
66
|
|
|
{ |
67
|
|
|
return new class($callback) implements ScheduleBuilder { |
|
|
|
|
68
|
|
|
public $calls = []; |
69
|
|
|
|
70
|
|
|
private $task; |
71
|
|
|
|
72
|
|
|
public function __construct(Task $task) |
73
|
|
|
{ |
74
|
|
|
$this->task = $task; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function buildSchedule(Schedule $schedule): void |
78
|
|
|
{ |
79
|
|
|
$schedule |
80
|
|
|
->filter(function () { $this->calls[] = 'scheduleFilter'; }) |
81
|
|
|
->before(function () { $this->calls[] = 'scheduleBefore'; }) |
82
|
|
|
->after(function () { $this->calls[] = 'scheduleAfter'; }) |
83
|
|
|
->onSuccess(function () { $this->calls[] = 'scheduleSuccess'; }) |
84
|
|
|
->onFailure(function () { $this->calls[] = 'scheduleFailure'; }) |
85
|
|
|
; |
86
|
|
|
|
87
|
|
|
$schedule->add($this->task) |
88
|
|
|
->filter(function () { $this->calls[] = 'taskFilter'; }) |
89
|
|
|
->before(function () { $this->calls[] = 'taskBefore'; }) |
90
|
|
|
->after(function () { $this->calls[] = 'taskAfter'; }) |
91
|
|
|
->onSuccess(function () { $this->calls[] = 'taskSuccess'; }) |
92
|
|
|
->onFailure(function () { $this->calls[] = 'taskFailure'; }) |
93
|
|
|
; |
94
|
|
|
} |
95
|
|
|
}; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
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