Skip to content

Commit

Permalink
fix: Root package is not loaded if it's not a brick (#30)
Browse files Browse the repository at this point in the history
Closes #29
  • Loading branch information
Gashmob authored May 28, 2024
2 parents 8c18791 + 01686ad commit bf6061c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
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

0 comments on commit bf6061c

Please sign in to comment.