Skip to content

Commit

Permalink
Refactor tests to use RefreshDatabase trait
Browse files Browse the repository at this point in the history
Removed manual migration calls in test setup and teardown in favor of using the RefreshDatabase trait to ensure a consistent state. Corrected a typo in migration file name within the service provider.
  • Loading branch information
CrazyBoy49z committed Sep 8, 2024
1 parent 73cf9c8 commit 55ac483
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/LazySettingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function configurePackage(Package $package): void
->name('lazy-setting')
->hasConfigFile('lazy/setting')
->hasViews()
->hasMigration('create_lazy-setting_table')
->hasMigration('create_lazy_setting_table')
->hasCommand(LazySettingCommand::class);
}

Expand Down
10 changes: 2 additions & 8 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<?php

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
use Step2Dev\LazySetting\Tests\TestCase;

uses(TestCase::class)->in(__DIR__);

beforeEach(function () {
Artisan::call('migrate');
});

afterEach(function () {
Artisan::call('migrate:reset');
});
6 changes: 2 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ protected function getPackageProviders($app)
];
}

public function getEnvironmentSetUp($app)
public function getEnvironmentSetUp($app): void
{
config()->set('database.default', 'testing');

/*
$migration = include __DIR__.'/../database/migrations/create_lazy-setting_table.php.stub';
$migration = include __DIR__.'/../database/migrations/create_lazy_setting_table.php.stub';
$migration->up();
*/
}
}

0 comments on commit 55ac483

Please sign in to comment.