zenstruck /
schedule-bundle
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Zenstruck\ScheduleBundle\Tests\Schedule\Extension; |
||
| 4 | |||
| 5 | use PHPUnit\Framework\TestCase; |
||
|
0 ignored issues
–
show
|
|||
| 6 | use Symfony\Contracts\HttpClient\HttpClientInterface; |
||
| 7 | use Zenstruck\ScheduleBundle\Schedule; |
||
| 8 | use Zenstruck\ScheduleBundle\Schedule\Extension\Handler\PingHandler; |
||
| 9 | use Zenstruck\ScheduleBundle\Schedule\ScheduleBuilder; |
||
| 10 | use Zenstruck\ScheduleBundle\Schedule\Task; |
||
| 11 | use Zenstruck\ScheduleBundle\Tests\Fixture\MockScheduleBuilder; |
||
| 12 | use Zenstruck\ScheduleBundle\Tests\Fixture\MockTask; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @author Kevin Bond <[email protected]> |
||
| 16 | */ |
||
| 17 | final class PingExtensionTest extends TestCase |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @test |
||
| 21 | */ |
||
| 22 | public function success_webhooks_are_pinged() |
||
| 23 | { |
||
| 24 | $client = $this->createMock(HttpClientInterface::class); |
||
| 25 | $client->expects($this->exactly(6))->method('request')->withConsecutive( |
||
| 26 | [$this->equalTo('GET'), $this->equalTo('schedule-before.com'), $this->isType('array')], |
||
| 27 | [$this->equalTo('GET'), $this->equalTo('task-before.com'), $this->isType('array')], |
||
| 28 | [$this->equalTo('GET'), $this->equalTo('task-after.com'), $this->isType('array')], |
||
| 29 | [$this->equalTo('GET'), $this->equalTo('task-success.com'), $this->isType('array')], |
||
| 30 | [$this->equalTo('GET'), $this->equalTo('schedule-after.com'), $this->isType('array')], |
||
| 31 | [$this->equalTo('GET'), $this->equalTo('schedule-success.com'), $this->isType('array')] |
||
| 32 | ); |
||
| 33 | |||
| 34 | (new MockScheduleBuilder()) |
||
| 35 | ->addHandler(new PingHandler($client)) |
||
| 36 | ->addBuilder($this->createBuilder(MockTask::success())) |
||
| 37 | ->run() |
||
| 38 | ; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @test |
||
| 43 | */ |
||
| 44 | public function failure_webhooks_are_pinged() |
||
| 45 | { |
||
| 46 | $client = $this->createMock(HttpClientInterface::class); |
||
| 47 | $client->expects($this->exactly(6))->method('request')->withConsecutive( |
||
| 48 | [$this->equalTo('GET'), $this->equalTo('schedule-before.com'), $this->isType('array')], |
||
| 49 | [$this->equalTo('GET'), $this->equalTo('task-before.com'), $this->isType('array')], |
||
| 50 | [$this->equalTo('GET'), $this->equalTo('task-after.com'), $this->isType('array')], |
||
| 51 | [$this->equalTo('GET'), $this->equalTo('task-failure.com'), $this->isType('array')], |
||
| 52 | [$this->equalTo('GET'), $this->equalTo('schedule-after.com'), $this->isType('array')], |
||
| 53 | [$this->equalTo('GET'), $this->equalTo('schedule-failure.com'), $this->isType('array')] |
||
| 54 | ); |
||
| 55 | |||
| 56 | (new MockScheduleBuilder()) |
||
| 57 | ->addHandler(new PingHandler($client)) |
||
| 58 | ->addBuilder($this->createBuilder(MockTask::exception(new \Exception()))) |
||
| 59 | ->run() |
||
| 60 | ; |
||
| 61 | } |
||
| 62 | |||
| 63 | private function createBuilder(Task $task): ScheduleBuilder |
||
| 64 | { |
||
| 65 | return new class($task) implements ScheduleBuilder { |
||
| 66 | private $task; |
||
| 67 | |||
| 68 | public function __construct(Task $task) |
||
| 69 | { |
||
| 70 | $this->task = $task; |
||
| 71 | } |
||
| 72 | |||
| 73 | public function buildSchedule(Schedule $schedule): void |
||
| 74 | { |
||
| 75 | $schedule |
||
| 76 | ->pingBefore('schedule-before.com') |
||
| 77 | ->pingAfter('schedule-after.com') |
||
| 78 | ->pingOnSuccess('schedule-success.com') |
||
| 79 | ->pingOnFailure('schedule-failure.com') |
||
| 80 | ; |
||
| 81 | |||
| 82 | $schedule->add($this->task) |
||
| 83 | ->pingBefore('task-before.com') |
||
| 84 | ->pingAfter('task-after.com') |
||
| 85 | ->pingOnSuccess('task-success.com') |
||
| 86 | ->pingOnFailure('task-failure.com') |
||
| 87 | ; |
||
| 88 | } |
||
| 89 | }; |
||
| 90 | } |
||
| 91 | } |
||
| 92 |
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