Merge pull request #1824 from nextcloud/downstream-26423

Ensure $commands being an array
This commit is contained in:
Morris Jobke 2016-10-20 20:43:26 +02:00 committed by GitHub
commit c7ba73e6f4
2 changed files with 11 additions and 7 deletions

View File

@ -197,6 +197,9 @@ class DependencyAnalyzer {
if (!is_array($commands)) {
$commands = array($commands);
}
if (isset($commands['@value'])) {
$commands = [$commands];
}
$os = $this->platform->getOS();
foreach ($commands as $command) {
if (isset($command['@attributes']['os']) && $command['@attributes']['os'] !== $os) {

View File

@ -256,17 +256,18 @@ class DependencyAnalyzerTest extends TestCase {
* @return array
*/
function providesCommands() {
return array(
array(array(), null),
return [
[[], null],
// grep is known on linux
array(array(), array(array('@attributes' => array('os' => 'Linux'), '@value' => 'grep'))),
[[], [['@attributes' => ['os' => 'Linux'], '@value' => 'grep']]],
// grepp is not known on linux
array(array('The command line tool grepp could not be found'), array(array('@attributes' => array('os' => 'Linux'), '@value' => 'grepp'))),
[['The command line tool grepp could not be found'], [['@attributes' => ['os' => 'Linux'], '@value' => 'grepp']]],
// we don't care about tools on Windows - we are on Linux
array(array(), array(array('@attributes' => array('os' => 'Windows'), '@value' => 'grepp'))),
[[], [['@attributes' => ['os' => 'Windows'], '@value' => 'grepp']]],
// grep is known on all systems
array(array(), 'grep'),
);
[[], 'grep'],
[[], ['@attributes' => ['os' => 'Linux'], '@value' => 'grep']],
];
}
/**