diff --git a/src/support/src/ServiceProvider.php b/src/support/src/ServiceProvider.php index 92a97a236..e186d4a34 100644 --- a/src/support/src/ServiceProvider.php +++ b/src/support/src/ServiceProvider.php @@ -255,8 +255,11 @@ public static function pathsToPublish(?string $provider = null, ?string $group = /** * Get the paths for the provider or group (or both). + * + * Returns null when no filter is specified, allowing caller to fall back to all paths. + * Returns empty array when a filter is specified but not found. */ - protected static function pathsForProviderOrGroup(?string $provider, ?string $group): array + protected static function pathsForProviderOrGroup(?string $provider, ?string $group): ?array { if ($provider && $group) { return static::pathsForProviderAndGroup($provider, $group); @@ -268,7 +271,9 @@ protected static function pathsForProviderOrGroup(?string $provider, ?string $gr return static::$publishes[$provider]; } - return []; + // Return [] if a filter was specified but not found + // Return null if no filter was specified (allows fallback to all paths) + return ($provider || $group) ? [] : null; } /** diff --git a/tests/Support/SupportServiceProviderTest.php b/tests/Support/SupportServiceProviderTest.php index fb69453ef..725c7e818 100644 --- a/tests/Support/SupportServiceProviderTest.php +++ b/tests/Support/SupportServiceProviderTest.php @@ -139,6 +139,36 @@ public function testPublishesMigrations() $this->assertContains('source/tagged/four', ServiceProvider::publishableMigrationPaths()); } + + public function testAllPathsAreReturnedWhenNoFilterIsSpecified() + { + $allPaths = ServiceProvider::pathsToPublish(); + + // Should contain paths from both providers + $this->assertArrayHasKey('source/unmarked/one', $allPaths); + $this->assertArrayHasKey('source/tagged/one', $allPaths); + $this->assertArrayHasKey('source/unmarked/two/a', $allPaths); + $this->assertArrayHasKey('source/tagged/two/a', $allPaths); + + // Should have all 11 paths from both providers + $this->assertCount(11, $allPaths); + } + + public function testEmptyArrayIsReturnedWhenProviderNotFound() + { + $paths = ServiceProvider::pathsToPublish('NonExistent\Provider'); + + $this->assertIsArray($paths); + $this->assertEmpty($paths); + } + + public function testEmptyArrayIsReturnedWhenGroupNotFound() + { + $paths = ServiceProvider::pathsToPublish(null, 'nonexistent_group'); + + $this->assertIsArray($paths); + $this->assertEmpty($paths); + } } class ServiceProviderForTestingOne extends ServiceProvider