Skip to content

Commit 09023eb

Browse files
Improve test to use artisan command instead of accessing static property
Co-authored-by: arietimmerman <[email protected]>
1 parent d043395 commit 09023eb

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

tests/ServiceProviderTest.php

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace ArieTimmerman\Laravel\SCIMServer\Tests;
44

55
use ArieTimmerman\Laravel\SCIMServer\ServiceProvider;
6+
use Illuminate\Support\Facades\Artisan;
67
use Orchestra\Testbench\TestCase as BaseTestCase;
78

89
class ServiceProviderTest extends BaseTestCase
@@ -12,42 +13,35 @@ protected function getPackageProviders($app)
1213
return [ServiceProvider::class];
1314
}
1415

15-
public function testMigrationsArePublishable()
16+
public function testMigrationsCanBePublished()
1617
{
17-
// Get the publishable groups
18-
$published = ServiceProvider::$publishes[ServiceProvider::class] ?? [];
19-
20-
// Check that the migration publishing is configured
21-
$migrationPublishes = collect($published)
22-
->filter(function ($destination, $source) {
23-
return str_contains($source, 'database/migrations');
24-
});
25-
26-
$this->assertNotEmpty($migrationPublishes, 'Migrations should be publishable');
18+
// Test that the vendor:publish command can find the migration tag
19+
$result = Artisan::call('vendor:publish', [
20+
'--tag' => 'laravel-scim-migrations',
21+
'--provider' => ServiceProvider::class,
22+
'--dry-run' => true,
23+
]);
24+
25+
// The command should succeed (return 0)
26+
$this->assertEquals(0, $result, 'Migrations should be publishable via vendor:publish command');
2727
}
2828

29-
public function testConfigIsPublishable()
29+
public function testConfigCanBePublished()
3030
{
31-
// Get the publishable groups
32-
$published = ServiceProvider::$publishes[ServiceProvider::class] ?? [];
33-
34-
// Check that the config publishing is configured
35-
$configPublishes = collect($published)
36-
->filter(function ($destination, $source) {
37-
return str_contains($source, 'config/scim.php');
38-
});
39-
40-
$this->assertNotEmpty($configPublishes, 'Config should be publishable');
31+
// Test that the vendor:publish command can find the config tag
32+
$result = Artisan::call('vendor:publish', [
33+
'--tag' => 'laravel-scim',
34+
'--provider' => ServiceProvider::class,
35+
'--dry-run' => true,
36+
]);
37+
38+
// The command should succeed (return 0)
39+
$this->assertEquals(0, $result, 'Config should be publishable via vendor:publish command');
4140
}
4241

43-
public function testMigrationsAreNotAutoLoaded()
42+
public function testMigrationFileExistsInPackage()
4443
{
45-
// Create an instance of the service provider
46-
$provider = new ServiceProvider($this->app);
47-
48-
// Use reflection to check if loadMigrationsFrom was called
49-
// Since we can't directly check if a migration path is loaded,
50-
// we just verify the migration file exists in the package
44+
// Verify the migration file exists in the package
5145
$migrationPath = realpath(__DIR__ . '/../database/migrations/2021_01_01_000003_add_scim_fields_to_users_table.php');
5246

5347
$this->assertFileExists($migrationPath, 'Migration file should exist in the package');

0 commit comments

Comments
 (0)