Skip to content

Commit

Permalink
Improved Service Provider and test
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet committed Mar 11, 2024
1 parent f54e72b commit eed4211
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/Providers/SqlReporterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function boot()
{
$this->publishes([
$this->configFileLocation() => config_path('sql-reporter.php'),
], 'config');
], 'sql-reporter');

if ($this->config->queriesEnabled()) {
DB::enableQueryLog();
Expand Down
32 changes: 32 additions & 0 deletions tests/Feature/SqlReporterServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Console\Events\CommandFinished;
use Illuminate\Foundation\Http\Events\RequestHandled;
use Illuminate\Support\Facades\Event;
use Onlime\LaravelSqlReporter\Listeners\LogSqlQuery;

it('registers event listeners', function (string $eventName) {
$listeners = Event::getRawListeners()[$eventName] ?? [];

expect($listeners)->not->toBeEmpty();
expect($listeners)->toContain(LogSqlQuery::class);
})->with([
CommandFinished::class,
RequestHandled::class,
]);

it('merges the default config', function () {
$config = config('sql-reporter');

expect($config)->toBeArray();
expect($config)->toHaveKey('queries');
expect($config)->toHaveKey('general');
});

it('can publish the config file', function () {
@unlink(config_path('sql-reporter.php'));

$this->artisan('vendor:publish', ['--tag' => 'sql-reporter']);

$this->assertFileExists(config_path('sql-reporter.php'));
});
40 changes: 0 additions & 40 deletions tests/Unit/SqlReporterServiceProviderTest.php

This file was deleted.

0 comments on commit eed4211

Please sign in to comment.