Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravmak committed Dec 17, 2018
1 parent b32f8c8 commit c8a0acd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/LogEnhancerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,41 @@ public function it_adds_request_details_to_logs()
}
}
}

/** @test */
public function it_skips_input_details_as_per_the_configuration()
{
$record = [];

config(['laravel_log_enhancer.log_input_data' => false]);

$requestDataProcessor = new RequestDataProcessor;
$record = $requestDataProcessor($record);

$this->assertArrayNotHasKey('headers', $record['extra']);
}

/** @test */
public function it_adds_other_details_as_per_the_configuration()
{
$record = [];

config(['laravel_log_enhancer.log_request_headers' => rand(0, 1)]);
config(['laravel_log_enhancer.log_session_data' => rand(0, 1)]);

$requestDataProcessor = new RequestDataProcessor;
$record = $requestDataProcessor($record);

if (config('laravel_log_enhancer.log_request_headers')) {
$this->assertArrayHasKey('headers', $record['extra']);
} else {
$this->assertArrayNotHasKey('headers', $record['extra']);
}

if (config('laravel_log_enhancer.log_session_data')) {
$this->assertArrayHasKey('session', $record['extra']);
} else {
$this->assertArrayNotHasKey('session', $record['extra']);
}
}
}

0 comments on commit c8a0acd

Please sign in to comment.