Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit f9ea35f

Browse files
Fixes test and names for migrations.
1 parent 00699b6 commit f9ea35f

File tree

1 file changed

+9
-32
lines changed

1 file changed

+9
-32
lines changed

tests/ServiceProviderTest.php

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,13 @@
66
use DarkGhostHunter\Laraconfig\LaraconfigServiceProvider;
77
use DarkGhostHunter\Laraconfig\Registrar\SettingRegistrar;
88
use Illuminate\Filesystem\Filesystem;
9-
use Illuminate\Support\Carbon;
9+
use Illuminate\Support\Str;
1010

1111
class ServiceProviderTest extends BaseTestCase
1212
{
13-
/** @var \Illuminate\Support\Carbon */
14-
static protected $now;
15-
1613
/** @var \Illuminate\Filesystem\Filesystem */
1714
protected mixed $filesystem;
1815

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-
2816
protected function setUp(): void
2917
{
3018
parent::setUp();
@@ -72,30 +60,19 @@ public function test_publishes_migrations(): void
7260
]
7361
)->run();
7462

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+
})
8369
);
8470
}
8571

8672
protected function tearDown(): void
8773
{
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'));
9976

10077
parent::tearDown();
10178
}

0 commit comments

Comments
 (0)