/** * 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, JSON_PRETTY_PRINT)); // Remove har file as it's work is done. unlink(self::get_har_file_path($capturelabel)); return true; }