/**
  * Start test plan.
  *
  * @param string $size size of the site.
  */
 public static function start_testplan($size)
 {
     global $CFG;
     $urlcomponents = parse_url($CFG->wwwroot);
     if (empty($urlcomponents['path'])) {
         $urlcomponents['path'] = '';
     }
     // Update fixed attributes.
     $propertiestoupdate = array('moodleversion' => $CFG->version, 'dataplansize' => get_config('core', 'performancesitedata'), 'host' => $urlcomponents['host'], 'sitepath' => $urlcomponents['path'], 'dataplanversion' => dataplanutil::get_tool_version(), 'testplansize' => $size, 'testplanversion' => util::get_tool_version());
     foreach ($propertiestoupdate as $prop => $value) {
         $list['//elementProp[@name=\'' . $prop . '\']//stringProp[@name=\'Argument.value\']'] = $value;
     }
     // Update throughput and any other global value found.
     $globalconfig = util::get_config();
     $globalconfig = $globalconfig['global'];
     foreach ($globalconfig as $key => $value) {
         if (is_array($value)) {
             $value = $value[$size];
         }
         $list['//stringProp[@name=\'' . $key . '\']'] = '${__property(throughput,throughput,' . $value . ')}';
     }
     self::replace_append_xml_in_testplan($list);
 }
 /**
  * Return information about what requests should be captured, with what params.
  *
  * @param string $capturelabel label.
  * @param string $featurefile name of the feature file.
  * @return array
  */
 private function get_capture_request_from_config($capturelabel, $featurefile)
 {
     $config = util::get_config();
     if (isset($config['scenarios'][$featurefile]['requests']) && array_key_exists($capturelabel, $config['scenarios'][$featurefile]['requests'])) {
         return $config['scenarios'][$featurefile]['requests'][$capturelabel];
     }
     return array();
 }
 /**
  * Save final har data approved by user.
  *
  * @param string $capturelabel capture label
  * @param array $request request to be saved.
  * @return bool true
  */
 public static function save_final_har_data($capturelabel, $request)
 {
     $updatedtestplanconfigfile = self::get_final_testplan_path() . DIRECTORY_SEPARATOR . 'testplan.json-dist';
     // If we have already written something then update the new file.
     if (file_exists($updatedtestplanconfigfile)) {
         $config = file_get_contents($updatedtestplanconfigfile);
         $config = json_decode($config, true);
     } else {
         $config = util::get_config();
     }
     $config['scenarios'][\behat_hooks::$featurefile]['requests'][$capturelabel] = $request;
     // Update config so it can be used in final release.
     file_put_contents($updatedtestplanconfigfile, json_encode($config));
     // Remove har file as it's work is done.
     unlink(self::get_har_file_path($capturelabel));
     return true;
 }