public static function update_config_file($component = '', $testsrunner = true, $tags = '',
        $themesuitewithallfeatures = false, $parallelruns = 0, $run = 0) {

        global $CFG;

        // Behat must have a separate behat.yml to have access to the whole set of features and steps definitions.
        if ($testsrunner === true) {
            $configfilepath = behat_command::get_behat_dir($run) . '/behat.yml';
        } else {
            // Alternative for steps definitions filtering, one for each user.
            $configfilepath = self::get_steps_list_config_filepath();
        }

        $behatconfigutil = self::get_behat_config_util();
        $behatconfigutil->set_theme_suite_to_include_core_features($themesuitewithallfeatures);
        $behatconfigutil->set_tag_for_feature_filter($tags);

        // Gets all the components with features, if running the tests otherwise not required.
        $features = array();
        if ($testsrunner) {
            $features = $behatconfigutil->get_components_features();
        }

        // Gets all the components with steps definitions.
        $stepsdefinitions = $behatconfigutil->get_components_contexts($component);
        // We don't want the deprecated steps definitions here.
        if (!$testsrunner) {
            unset($stepsdefinitions['behat_deprecated']);
        }

        // Get current run.
        if (empty($run) && ($run !== false) && !empty($CFG->behatrunprocess)) {
            $run = $CFG->behatrunprocess;
        }

        // Get number of parallel runs if not passed.
        if (empty($parallelruns) && ($parallelruns !== false)) {
            $parallelruns = self::get_behat_run_config_value('parallel');
        }

        // Behat config file specifing the main context class,
        // the required Behat extensions and Moodle test wwwroot.
        $contents = $behatconfigutil->get_config_file_contents($features, $stepsdefinitions, $tags, $parallelruns, $run);

        // Stores the file.
        if (!file_put_contents($configfilepath, $contents)) {
            behat_error(BEHAT_EXITCODE_PERMISSIONS, 'File ' . $configfilepath . ' can not be created');
        }

    }