55use DarkGhostHunter \Laraconfig \Facades \Setting ;
66use DarkGhostHunter \Laraconfig \LaraconfigServiceProvider ;
77use DarkGhostHunter \Laraconfig \Registrar \SettingRegistrar ;
8+ use Illuminate \Filesystem \Filesystem ;
9+ use Illuminate \Support \Carbon ;
810
911class ServiceProviderTest extends BaseTestCase
1012{
13+ /** @var \Illuminate\Support\Carbon */
14+ static protected $ now ;
15+
16+ /** @var \Illuminate\Filesystem\Filesystem */
17+ protected mixed $ filesystem ;
18+
19+ public static function setUpBeforeClass (): void
20+ {
21+ parent ::setUpBeforeClass ();
22+
23+ static ::$ now = Carbon::create (2020 , 1 , 1 , 19 , 30 );
24+
25+ Carbon::setTestNow (static ::$ now );
26+ }
27+
28+ protected function setUp (): void
29+ {
30+ parent ::setUp ();
31+
32+ $ this ->filesystem = $ this ->app ->make (Filesystem::class);
33+ }
34+
1135 public function test_registers_package (): void
1236 {
1337 static ::assertArrayHasKey (LaraconfigServiceProvider::class, $ this ->app ->getLoadedProviders ());
@@ -33,8 +57,46 @@ public function test_publishes_config(): void
3357 ]
3458 )->execute ();
3559
36- $ this ->assertFileEquals (base_path ('config/laraconfig.php ' ), __DIR__ . '/../config/laraconfig.php ' );
60+ static ::assertFileEquals (base_path ('config/laraconfig.php ' ), __DIR__ . '/../config/laraconfig.php ' );
61+ }
62+
63+ public function test_publishes_migrations (): void
64+ {
65+ $ this ->filesystem ->ensureDirectoryExists (database_path ('migrations ' ));
66+
67+ $ this ->artisan (
68+ 'vendor:publish ' ,
69+ [
70+ '--provider ' => 'DarkGhostHunter\Laraconfig\LaraconfigServiceProvider ' ,
71+ '--tag ' => 'migrations ' ,
72+ ]
73+ )->run ();
74+
75+ static ::assertFileEquals (
76+ database_path ('migrations/2020_01_01_193000_create_user_settings_table.php ' ),
77+ __DIR__ . '/../database/migrations/00_00_00_000000_create_user_settings_table.php '
78+ );
79+
80+ static ::assertFileEquals (
81+ database_path ('migrations/2020_01_01_193000_create_user_settings_metadata_table.php ' ),
82+ __DIR__ . '/../database/migrations/00_00_00_000000_create_user_settings_metadata_table.php '
83+ );
84+ }
85+
86+ protected function tearDown (): void
87+ {
88+ if ($ this ->filesystem ->exists (base_path ('config/laraconfig.php ' ))) {
89+ $ this ->filesystem ->delete (base_path ('config/laraconfig.php ' ));
90+ }
91+
92+ if ($ this ->filesystem ->exists (database_path ('00_00_00_000000_create_user_settings_metadata_table.php ' ))) {
93+ $ this ->filesystem ->delete (database_path ('00_00_00_000000_create_user_settings_metadata_table.php ' ));
94+ }
95+
96+ if ($ this ->filesystem ->exists (database_path ('00_00_00_000000_create_user_settings_metadata_table.php ' ))) {
97+ $ this ->filesystem ->delete (database_path ('00_00_00_000000_create_user_settings_metadata_table.php ' ));
98+ }
3799
38- unlink ( base_path ( ' config/laraconfig.php ' ) );
100+ parent :: tearDown ( );
39101 }
40- }
102+ }
0 commit comments