Skip to content

Commit c64bb46

Browse files
committed
Refactor tests to use Pest artisan helper
1 parent 80309a8 commit c64bb46

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tests/Commands/MakeMetricsTableTest.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,25 @@
33
use DirectoryTree\Metrics\Commands\MakeMetricsTable;
44
use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles;
55

6+
use function Pest\Laravel\artisan;
7+
68
uses(InteractsWithPublishedFiles::class);
79

810
it('creates a migration file with the correct name', function () {
9-
$this->artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
11+
artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
1012
->assertSuccessful();
1113

1214
$this->assertMigrationFileExists('*_create_test_metrics_table.php');
1315
});
1416

1517
it('displays success message with migration name', function () {
16-
$this->artisan(MakeMetricsTable::class, ['name' => 'user_metrics'])
18+
artisan(MakeMetricsTable::class, ['name' => 'user_metrics'])
1719
->expectsOutputToContain('created successfully')
1820
->assertSuccessful();
1921
});
2022

2123
it('generates migration with correct table name in schema', function () {
22-
$this->artisan(MakeMetricsTable::class, ['name' => 'custom_metrics'])
24+
artisan(MakeMetricsTable::class, ['name' => 'custom_metrics'])
2325
->assertSuccessful();
2426

2527
$this->assertMigrationFileContains([
@@ -29,7 +31,7 @@
2931
});
3032

3133
it('generates migration with all required columns', function () {
32-
$this->artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
34+
artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
3335
->assertSuccessful();
3436

3537
$this->assertMigrationFileContains([
@@ -47,7 +49,7 @@
4749
});
4850

4951
it('generates migration with correct index', function () {
50-
$this->artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
52+
artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
5153
->assertSuccessful();
5254

5355
$this->assertMigrationFileContains([
@@ -56,7 +58,7 @@
5658
});
5759

5860
it('generates migration with up and down methods', function () {
59-
$this->artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
61+
artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
6062
->assertSuccessful();
6163

6264
$this->assertMigrationFileContains([
@@ -66,19 +68,19 @@
6668
});
6769

6870
it('creates migration file with timestamp prefix', function () {
69-
$this->artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
71+
artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
7072
->assertSuccessful();
7173

7274
$this->assertMigrationFileExists('*_create_test_metrics_table.php');
7375
});
7476

7577
it('can generate multiple different metrics tables', function () {
76-
$this->artisan(MakeMetricsTable::class, ['name' => 'user_metrics'])
78+
artisan(MakeMetricsTable::class, ['name' => 'user_metrics'])
7779
->assertSuccessful();
7880

7981
sleep(1); // Ensure different timestamp
8082

81-
$this->artisan(MakeMetricsTable::class, ['name' => 'custom_metrics'])
83+
artisan(MakeMetricsTable::class, ['name' => 'custom_metrics'])
8284
->assertSuccessful();
8385

8486
$this->assertMigrationFileExists('*_create_user_metrics_table.php');
@@ -94,7 +96,7 @@
9496
});
9597

9698
it('generates valid php migration file', function () {
97-
$this->artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
99+
artisan(MakeMetricsTable::class, ['name' => 'test_metrics'])
98100
->assertSuccessful();
99101

100102
$this->assertMigrationFileContains([

0 commit comments

Comments
 (0)