55use DarkGhostHunter \Laraconfig \Facades \Setting ;
66use DarkGhostHunter \Laraconfig \LaraconfigServiceProvider ;
77use DarkGhostHunter \Laraconfig \Registrar \SettingRegistrar ;
8+ use Illuminate \Filesystem \Filesystem ;
9+ use Illuminate \Support \Str ;
810
911class ServiceProviderTest extends BaseTestCase
1012{
13+ /** @var \Illuminate\Filesystem\Filesystem */
14+ protected mixed $ filesystem ;
15+
16+ protected function setUp (): void
17+ {
18+ parent ::setUp ();
19+
20+ $ this ->filesystem = $ this ->app ->make (Filesystem::class);
21+ }
22+
1123 public function test_registers_package (): void
1224 {
1325 static ::assertArrayHasKey (LaraconfigServiceProvider::class, $ this ->app ->getLoadedProviders ());
@@ -33,8 +45,35 @@ public function test_publishes_config(): void
3345 ]
3446 )->execute ();
3547
36- $ this ->assertFileEquals (base_path ('config/laraconfig.php ' ), __DIR__ . '/../config/laraconfig.php ' );
48+ static ::assertFileEquals (base_path ('config/laraconfig.php ' ), __DIR__ . '/../config/laraconfig.php ' );
49+ }
50+
51+ public function test_publishes_migrations (): void
52+ {
53+ $ this ->filesystem ->ensureDirectoryExists (database_path ('migrations ' ));
54+
55+ $ this ->artisan (
56+ 'vendor:publish ' ,
57+ [
58+ '--provider ' => 'DarkGhostHunter\Laraconfig\LaraconfigServiceProvider ' ,
59+ '--tag ' => 'migrations ' ,
60+ ]
61+ )->run ();
62+
63+ static ::assertTrue (
64+ collect ($ this ->filesystem ->files ($ this ->app ->databasePath ('migrations ' )))
65+ ->contains (function (\SplFileInfo $ file ) {
66+ return Str::endsWith ($ file ->getPathname (), '_create_user_settings_table.php ' )
67+ || Str::endsWith ($ file ->getPathname (), '_create_user_settings_metadata_table.php ' );
68+ })
69+ );
70+ }
71+
72+ protected function tearDown (): void
73+ {
74+ $ this ->filesystem ->delete (base_path ('config/laraconfig.php ' ));
75+ $ this ->filesystem ->cleanDirectory (database_path ('migrations ' ));
3776
38- unlink ( base_path ( ' config/laraconfig.php ' ) );
77+ parent :: tearDown ( );
3978 }
40- }
79+ }
0 commit comments