From 49cfef520a64656ead95011a540381ebc63c24d0 Mon Sep 17 00:00:00 2001 From: Adriaan Zonnenberg Date: Fri, 18 Mar 2022 15:02:23 +0100 Subject: [PATCH] Add test for no configured channel --- tests/Integration/LogTest.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/Integration/LogTest.php b/tests/Integration/LogTest.php index 57bc610..f2057fe 100644 --- a/tests/Integration/LogTest.php +++ b/tests/Integration/LogTest.php @@ -14,12 +14,31 @@ class LogTest extends TestCase { use RefreshDatabase; - protected function defineEnvironment($app) + protected function usesNullLogChannel($app) { $app['config']->set('telescope-monitor.log_channel', 'null'); } - public function testExeptionsGetLoggedToLogConfiguredChannel() + public function testExceptionsDontGetLoggedWithoutConfiguration() + { + $exception = new Exception('whoops'); + + Telescope::recordException(new IncomingExceptionEntry($exception, [ + 'class' => get_class($exception), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + 'message' => $exception->getMessage(), + 'trace' => $exception->getTrace(), + 'line_preview' => ExceptionContext::get($exception), + ])); + + Log::shouldReceive('channel->error')->never(); + + $this->app->call(Telescope::store(...)); + } + + /** @define-env usesNullLogChannel */ + public function testExceptionsGetLoggedToLogConfiguredChannel() { $exception = new Exception('whoops'); @@ -34,7 +53,7 @@ public function testExeptionsGetLoggedToLogConfiguredChannel() Log::shouldReceive('channel->error')->once()->with('whoops', [ 'type' => Exception::class, - 'location' => __FILE__ . ':' . 24, + 'location' => __FILE__ . ':' . 43, 'details' => 'http://localhost/telescope/exceptions/' . $entry->uuid, ]);