Skip to content

Commit

Permalink
Add test for no configured channel
Browse files Browse the repository at this point in the history
  • Loading branch information
adriaanzon committed Mar 18, 2022
1 parent b782eb5 commit 49cfef5
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions tests/Integration/LogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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,
]);

Expand Down

0 comments on commit 49cfef5

Please sign in to comment.