Skip to content

Commit 6075a96

Browse files
committed
Merge pull request magento-hackathon#29 from SlayerBirden/array_combine_fix
fix for array_combine and php 5.3
2 parents 5bcc78c + 1a8e211 commit 6075a96

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

src/MagentoHackathon/Composer/Magento/ModuleManager.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,17 @@ public function doRemoves(array $packagesToRemove)
137137
public function getRemoves(array $currentComposerInstalledPackages, array $magentoInstalledPackages)
138138
{
139139
//make the package names as the array keys
140-
$currentComposerInstalledPackages = array_combine(
141-
array_map(
142-
function (PackageInterface $package) {
143-
return $package->getPrettyName();
144-
},
140+
if (count($currentComposerInstalledPackages)) {
141+
$currentComposerInstalledPackages = array_combine(
142+
array_map(
143+
function (PackageInterface $package) {
144+
return $package->getPrettyName();
145+
},
146+
$currentComposerInstalledPackages
147+
),
145148
$currentComposerInstalledPackages
146-
),
147-
$currentComposerInstalledPackages
148-
);
149-
149+
);
150+
}
150151
return array_filter(
151152
$magentoInstalledPackages,
152153
function (InstalledPackage $package) use ($currentComposerInstalledPackages) {

tests/MagentoHackathon/Composer/Magento/ModuleManagerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,19 @@ public function testMultipleInstallsAndUnInstalls()
117117
$this->assertSame($installedMagentoPackages, $result[0]);
118118
$this->assertSame($composerInstalledPackages, $result[1]);
119119
}
120+
121+
public function testEmptyComposerInstalledPackages()
122+
{
123+
$installedMagentoPackages = array(
124+
new InstalledPackage("vendor/package1", "1.0.0", array()),
125+
new InstalledPackage("vendor/package2", "1.0.0", array()),
126+
);
127+
128+
$this->installedPackageRepository->add($installedMagentoPackages[0]);
129+
$this->installedPackageRepository->add($installedMagentoPackages[1]);
130+
131+
$result = $this->moduleManager->updateInstalledPackages(array());
132+
$this->assertSame($installedMagentoPackages, $result[0]);
133+
$this->assertEmpty($result[1]);
134+
}
120135
}

0 commit comments

Comments
 (0)