Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/support/src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

/**
Expand Down
30 changes: 30 additions & 0 deletions tests/Support/SupportServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down