|
6 | 6 | use DarkGhostHunter\Laraconfig\LaraconfigServiceProvider; |
7 | 7 | use DarkGhostHunter\Laraconfig\Registrar\SettingRegistrar; |
8 | 8 | use Illuminate\Filesystem\Filesystem; |
9 | | -use Illuminate\Support\Carbon; |
| 9 | +use Illuminate\Support\Str; |
10 | 10 |
|
11 | 11 | class ServiceProviderTest extends BaseTestCase |
12 | 12 | { |
13 | | - /** @var \Illuminate\Support\Carbon */ |
14 | | - static protected $now; |
15 | | - |
16 | 13 | /** @var \Illuminate\Filesystem\Filesystem */ |
17 | 14 | protected mixed $filesystem; |
18 | 15 |
|
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 | 16 | protected function setUp(): void |
29 | 17 | { |
30 | 18 | parent::setUp(); |
@@ -72,30 +60,19 @@ public function test_publishes_migrations(): void |
72 | 60 | ] |
73 | 61 | )->run(); |
74 | 62 |
|
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' |
| 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 | + }) |
83 | 69 | ); |
84 | 70 | } |
85 | 71 |
|
86 | 72 | protected function tearDown(): void |
87 | 73 | { |
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 | | - } |
| 74 | + $this->filesystem->delete(base_path('config/laraconfig.php')); |
| 75 | + $this->filesystem->cleanDirectory(database_path('migrations')); |
99 | 76 |
|
100 | 77 | parent::tearDown(); |
101 | 78 | } |
|
0 commit comments