|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Spiral\RoadRunnerLaravel\Tests\Unit\Listeners; |
| 6 | + |
| 7 | +use Mockery as m; |
| 8 | +use Spatie\LaravelIgnition\Recorders; |
| 9 | +use Spiral\RoadRunnerLaravel\Events\Contracts\WithApplication; |
| 10 | +use Spiral\RoadRunnerLaravel\Listeners\ResetLaravelIgnitionListener; |
| 11 | + |
| 12 | +/** |
| 13 | + * @covers \Spiral\RoadRunnerLaravel\Listeners\ResetLaravelIgnitionListener |
| 14 | + */ |
| 15 | +class ResetLaravelIgnitionListenerTest extends AbstractListenerTestCase |
| 16 | +{ |
| 17 | + /** |
| 18 | + * {@inheritdoc} |
| 19 | + */ |
| 20 | + public function testHandle(): void |
| 21 | + { |
| 22 | + if (!\class_exists(\Spatie\LaravelIgnition\IgnitionServiceProvider::class)) { |
| 23 | + $this->markTestSkipped("Run 'composer require --dev spatie/laravel-ignition' for enabling this test"); |
| 24 | + } |
| 25 | + |
| 26 | + $this->spy(\Spatie\Ignition\Ignition::class, function (m\MockInterface $m) { |
| 27 | + $m->shouldReceive('reset')->once(); |
| 28 | + }); |
| 29 | + |
| 30 | + $this->spy(\Spatie\LaravelIgnition\Support\SentReports::class, function (m\MockInterface $m) { |
| 31 | + $m->shouldReceive('clear')->once(); |
| 32 | + }); |
| 33 | + |
| 34 | + $this->spy(Recorders\DumpRecorder\DumpRecorder::class, function (m\MockInterface $m) { |
| 35 | + $m->shouldReceive('reset')->once(); |
| 36 | + }); |
| 37 | + |
| 38 | + $this->spy(Recorders\LogRecorder\LogRecorder::class, function (m\MockInterface $m) { |
| 39 | + $m->shouldReceive('reset')->once(); |
| 40 | + }); |
| 41 | + |
| 42 | + $this->spy(Recorders\QueryRecorder\QueryRecorder::class, function (m\MockInterface $m) { |
| 43 | + $m->shouldReceive('reset')->once(); |
| 44 | + }); |
| 45 | + |
| 46 | + $this->spy(Recorders\JobRecorder\JobRecorder::class, function (m\MockInterface $m) { |
| 47 | + $m->shouldReceive('reset')->once(); |
| 48 | + }); |
| 49 | + |
| 50 | + /** @var m\MockInterface|WithApplication $event_mock */ |
| 51 | + $event_mock = m::mock(WithApplication::class) |
| 52 | + ->makePartial() |
| 53 | + ->expects('application') |
| 54 | + ->andReturn($this->app) |
| 55 | + ->getMock(); |
| 56 | + |
| 57 | + $this->listenerFactory()->handle($event_mock); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * @return ResetLaravelIgnitionListener |
| 62 | + */ |
| 63 | + protected function listenerFactory(): ResetLaravelIgnitionListener |
| 64 | + { |
| 65 | + return new ResetLaravelIgnitionListener(); |
| 66 | + } |
| 67 | +} |
0 commit comments