Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Root package is not loaded if it's not a brick #30

Merged
merged 1 commit into from
May 28, 2024
Merged
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
3 changes: 2 additions & 1 deletion include/Bricks/LoadBricks.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
{
public function loadInstalledBricks(): array
{
$packages = array_unique(InstalledVersions::getInstalledPackagesByType(self::PACKAGE_TYPE));
$root = InstalledVersions::getRootPackage()['name'];
$packages = array_unique([$root, ...InstalledVersions::getInstalledPackagesByType(self::PACKAGE_TYPE)]);

$result = [];
foreach ($packages as $package_name) {
Expand Down
14 changes: 8 additions & 6 deletions tests/unit/Bricks/LoadBricksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ public function testItLoadBrick(): void
$loader = new LoadBricks();
$bricks = $loader->loadInstalledBricks();

self::assertCount(1, $bricks);
$brick = $bricks[0];
self::assertSame('brick1', $brick->package_name);
self::assertSame(__DIR__ . '/../Fixtures/brick1', $brick->package_path);
self::assertCount(1, $brick->services);
$service = $brick->services[0];
self::assertCount(2, $bricks);
$brick1 = $bricks[0];
self::assertSame('archict/core', $brick1->package_name); // Current package
$brick2 = $bricks[1];
self::assertSame('brick1', $brick2->package_name);
self::assertSame(__DIR__ . '/../Fixtures/brick1', $brick2->package_path);
self::assertCount(1, $brick2->services);
$service = $brick2->services[0];
self::assertSame(Service1::class, $service->reflection->name);
self::assertSame('bar.yml', $service->service_attribute->configuration_filename);
self::assertSame(Service1Configuration::class, $service->service_attribute->configuration_classname);
Expand Down