Skip to content

Commit

Permalink
MDL-71386 behat: Support for 3.9.5+ mobile app
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelDeMartin committed Apr 22, 2021
1 parent e29b256 commit 168f28f
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions lib/behat/classes/behat_config_util.php
Expand Up @@ -731,17 +731,28 @@ protected function get_mobile_version_tags($verbose = true) : string {
}
$installedversion = $package->version;
} else if (!empty($CFG->behat_ionic_wwwroot)) {
// Get app version from config.json inside wwwroot.
$jsonurl = $CFG->behat_ionic_wwwroot . '/config.json';
$json = @download_file_content($jsonurl);
// Get app version from env.json inside wwwroot.
$jsonurl = $CFG->behat_ionic_wwwroot . '/assets/env.json';
$json = @file_get_contents($jsonurl);
if (!$json) {
throw new coding_exception('Unable to load app version from ' . $jsonurl);
}
$config = json_decode($json);
if ($config === null || empty($config->versionname)) {
throw new coding_exception('Invalid app config data in ' . $jsonurl);
// Fall back to ionic 3 config file.
$jsonurl = $CFG->behat_ionic_wwwroot . '/config.json';
$json = @file_get_contents($jsonurl);
if (!$json) {
throw new coding_exception('Unable to load app version from ' . $jsonurl);
}
$config = json_decode($json);
if ($config === null || empty($config->versionname)) {
throw new coding_exception('Invalid app config data in ' . $jsonurl);
}
$installedversion = str_replace('-dev', '', $config->versionname);
} else {
$env = json_decode($json);
if (empty($env->build->version ?? null)) {
throw new coding_exception('Invalid app config data in ' . $jsonurl);
}
$installedversion = $env->build->version;
}
$installedversion = str_replace('-dev', '', $config->versionname);
} else {
return '';
}
Expand Down

0 comments on commit 168f28f

Please sign in to comment.