From fedd672e3c8570e3d4b4e96dd7014a9a7bec8800 Mon Sep 17 00:00:00 2001 From: Erik Gaal Date: Wed, 4 Sep 2019 15:21:38 +0200 Subject: [PATCH] Add regression test for resuming recording with sync jobs --- tests/Telescope/TelescopeTest.php | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/Telescope/TelescopeTest.php b/tests/Telescope/TelescopeTest.php index f7ad2925e..fd95486db 100644 --- a/tests/Telescope/TelescopeTest.php +++ b/tests/Telescope/TelescopeTest.php @@ -3,6 +3,8 @@ namespace Laravel\Telescope\Tests\Telescope; use Laravel\Telescope\Telescope; +use Illuminate\Contracts\Bus\Dispatcher; +use Illuminate\Contracts\Queue\ShouldQueue; use Laravel\Telescope\Tests\FeatureTestCase; use Laravel\Telescope\Watchers\QueryWatcher; use Laravel\Telescope\Contracts\EntriesRepository; @@ -70,4 +72,37 @@ public function after_recording_callback_can_store_and_flush() $this->assertCount(1, Telescope::$entriesQueue); } + + /** + * @test + */ + public function dont_start_recording_when_dispatching_job_synchronously() + { + Telescope::stopRecording(); + + $this->assertFalse(Telescope::isRecording()); + + $this->app->get(Dispatcher::class)->dispatch( + new MySyncJob('Awesome Laravel') + ); + + $this->assertFalse(Telescope::isRecording()); + } +} + +class MySyncJob implements ShouldQueue +{ + public $connection = 'sync'; + + private $payload; + + public function __construct($payload) + { + $this->payload = $payload; + } + + public function handle() + { + // + } }